Compare commits
79 Commits
build/1.21
...
dev/1.21.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a020337531 | ||
|
|
bcf356ff4a | ||
|
|
eead936c54 | ||
|
|
55fbffae38 | ||
|
|
637b0ef8cb | ||
|
|
4904f64392 | ||
|
|
7456362b05 | ||
|
|
d9625f4213 | ||
|
|
7fac157785 | ||
|
|
14403ebab9 | ||
|
|
fb72bc56c3 | ||
|
|
4e0b4a2732 | ||
|
|
96cb741c0e | ||
|
|
8b0a4c75c5 | ||
|
|
e286d62894 | ||
|
|
883f334864 | ||
|
|
063137dce4 | ||
|
|
6958022ef9 | ||
|
|
7e1f20905c | ||
|
|
b9b81666d7 | ||
|
|
fc74a019dc | ||
|
|
5788942629 | ||
|
|
0c58a0b04a | ||
|
|
379451fec5 | ||
|
|
fae89fb86d | ||
|
|
b1368732a3 | ||
|
|
ebe98dd7f4 | ||
|
|
6d6a60fcde | ||
|
|
02ffa930f1 | ||
|
|
eb4036a64d | ||
|
|
1764f1095e | ||
|
|
22bcf63585 | ||
|
|
86b9aa41cc | ||
|
|
e55f818ab2 | ||
|
|
e54f3fcf11 | ||
|
|
3f15d7a684 | ||
|
|
851cab54e0 | ||
|
|
f63645c2fb | ||
|
|
8062ccb4ed | ||
|
|
c0d36db38d | ||
|
|
62f90e3fba | ||
|
|
2986abeee1 | ||
|
|
fc38239b61 | ||
|
|
cfe2db6181 | ||
|
|
8975d5676b | ||
|
|
3e1399c421 | ||
|
|
d110f25a23 | ||
|
|
7543f3adbd | ||
|
|
6a16940e2b | ||
|
|
5596d998c1 | ||
|
|
75fad4cd35 | ||
|
|
f476809251 | ||
|
|
269cbb507b | ||
|
|
54dfd7163a | ||
|
|
d975acec6b | ||
|
|
72565bec8e | ||
|
|
05215498c3 | ||
|
|
ae94d43098 | ||
|
|
8889a877d6 | ||
|
|
e915eadfad | ||
|
|
28ce30ec48 | ||
|
|
dd8042f88a | ||
|
|
54bc879a9e | ||
|
|
33701c1eca | ||
|
|
2028e19bf8 | ||
|
|
7a7a88a7bb | ||
|
|
8860cedaf7 | ||
|
|
527b6c7eaf | ||
|
|
e37f05bd87 | ||
|
|
dfb64f50db | ||
|
|
69d4f4bf86 | ||
|
|
64802e7e50 | ||
|
|
a313424212 | ||
|
|
fa3c15b4f3 | ||
|
|
393e079743 | ||
|
|
90d412bbf3 | ||
|
|
98cf5b2d13 | ||
|
|
32243963f5 | ||
|
|
72183c64b9 |
@@ -9,7 +9,7 @@ ij_any_block_comment_at_first_column = false
|
|||||||
ij_any_line_comment_at_first_column = false
|
ij_any_line_comment_at_first_column = false
|
||||||
ij_any_line_comment_add_space = true
|
ij_any_line_comment_add_space = true
|
||||||
max_line_length = 120
|
max_line_length = 120
|
||||||
ij_visual_guides = 80
|
ij_visual_guides = 16, 80
|
||||||
|
|
||||||
[*.tiny]
|
[*.tiny]
|
||||||
indent_style=tab
|
indent_style=tab
|
||||||
@@ -19,6 +19,7 @@ end_of_line=crlf
|
|||||||
|
|
||||||
[*.yml]
|
[*.yml]
|
||||||
indent_size=2
|
indent_size=2
|
||||||
|
ij_visual_guides = 8, 80
|
||||||
|
|
||||||
[*.patch]
|
[*.patch]
|
||||||
trim_trailing_whitespace=false
|
trim_trailing_whitespace=false
|
||||||
|
|||||||
6
.github/workflows/gradle.yml
vendored
6
.github/workflows/gradle.yml
vendored
@@ -23,13 +23,13 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout action
|
- name: Checkout action
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Validate Gradle Wrapper
|
- name: Validate Gradle Wrapper
|
||||||
uses: gradle/wrapper-validation-action@v1
|
uses: gradle/actions/wrapper-validation@v4
|
||||||
|
|
||||||
- name: Set up JDK ${{ matrix.java }} ${{ matrix.jdk }}
|
- name: Set up JDK ${{ matrix.java }} ${{ matrix.jdk }}
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: ${{ matrix.java }}
|
distribution: ${{ matrix.java }}
|
||||||
java-version: ${{ matrix.jdk }}
|
java-version: ${{ matrix.jdk }}
|
||||||
|
|||||||
12
.github/workflows/release.yaml
vendored
Normal file
12
.github/workflows/release.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
name: Release Plazma
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "ver/*", "dev/*", "feat/**/*" ]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Release Plazma (${{ github.ref_name }})
|
||||||
|
uses: PlazmaMC/PlazmaBukkit/.github/workflows/global.yaml@main
|
||||||
|
secrets: inherit
|
||||||
146
.github/workflows/release.yml
vendored
146
.github/workflows/release.yml
vendored
@@ -1,146 +0,0 @@
|
|||||||
name: Release Plazma (1.21.3)
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "ver/*", "dev/*", "feat/**/*" ]
|
|
||||||
paths:
|
|
||||||
- "patches/server/**.patch"
|
|
||||||
- "patches/api/**.patch"
|
|
||||||
- "gradle.properties"
|
|
||||||
- "release.yml"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
ORG_NAME: PlazmaMC
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
name: Release Plazma
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
base_jdk: [21]
|
|
||||||
os: [ubuntu-22.04]
|
|
||||||
|
|
||||||
if: "!startsWith(github.event.commits[0].message, '[CI-Skip]')"
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Setup Variables
|
|
||||||
id: setup
|
|
||||||
env:
|
|
||||||
BRANCH: ${{ github.ref_name }}
|
|
||||||
run: echo "VERSION=${BRANCH##*/}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Checkout javadocs
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
continue-on-error: true
|
|
||||||
if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/')
|
|
||||||
with:
|
|
||||||
repository: PlazmaMC/Javadocs
|
|
||||||
ref: ${{ env.VERSION }}
|
|
||||||
token: ${{ secrets.GH_PAT }}
|
|
||||||
path: javadoc
|
|
||||||
|
|
||||||
- name: Checkout javadocs
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/')
|
|
||||||
with:
|
|
||||||
repository: PlazmaMC/Javadocs
|
|
||||||
token: ${{ secrets.GH_PAT }}
|
|
||||||
path: jdmain
|
|
||||||
|
|
||||||
- name: Validate Gradle Wrapper
|
|
||||||
uses: gradle/wrapper-validation-action@v1
|
|
||||||
|
|
||||||
- name: Set up GraalVM ${{ matrix.base_jdk }}
|
|
||||||
uses: graalvm/setup-graalvm@v1
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
java-version: ${{ matrix.base_jdk }}
|
|
||||||
version: latest
|
|
||||||
cache: 'gradle'
|
|
||||||
|
|
||||||
- name: Configure Git
|
|
||||||
run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" && git config --global user.name "github-actions[bot]"
|
|
||||||
|
|
||||||
- name: Get Release Number
|
|
||||||
if: startsWith(github.ref_name, 'ver/')
|
|
||||||
run: echo "BUILD_NUMBER=$(git ls-remote --tags origin | grep "build/${{ env.VERSION }}" | wc -l)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Apply Patches
|
|
||||||
run: ./gradlew applyPatches --stacktrace
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: ./gradlew build --stacktrace
|
|
||||||
|
|
||||||
- name: Create Reobf Jar
|
|
||||||
run: ./gradlew createReobfPaperclipJar --stacktrace
|
|
||||||
|
|
||||||
- name: Create Mojmap Jar
|
|
||||||
run: ./gradlew createMojmapPaperclipJar --stacktrace
|
|
||||||
|
|
||||||
- name: Update Javadoc
|
|
||||||
if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/')
|
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
|
||||||
if [ ! -d "javadoc" ]; then
|
|
||||||
SUBMODULE_ADD=true
|
|
||||||
mkdir javadoc && cd javadoc
|
|
||||||
git init && git branch -m ${{ env.VERSION }}
|
|
||||||
git remote add origin https://github.com/PlazmaMC/Javadocs
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp -rf Plazma-API/build/docs/javadoc/* javadoc/
|
|
||||||
cd javadoc
|
|
||||||
git add . && git commit -m "Update Javadocs"
|
|
||||||
git push -f origin ${{ env.VERSION }}
|
|
||||||
|
|
||||||
cd ../jdmain
|
|
||||||
if [ $SUBMODULE_ADD = true ]; then
|
|
||||||
git submodule add -b ${{ env.VERSION }} https://github.com/PlazmaMC/Javadocs ${{ env.VERSION }}
|
|
||||||
fi
|
|
||||||
git submodule update
|
|
||||||
git add . && git commit -m "Update Javadocs"
|
|
||||||
git push
|
|
||||||
|
|
||||||
- name: Publish Packages
|
|
||||||
if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/')
|
|
||||||
run: |
|
|
||||||
export GITHUB_USERNAME=${{ env.ORG_NAME }}
|
|
||||||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
|
||||||
./gradlew publish --stacktrace
|
|
||||||
|
|
||||||
- name: Release Artifacts
|
|
||||||
if: startsWith(github.ref_name, 'ver/')
|
|
||||||
uses: softprops/action-gh-release@v0.1.15
|
|
||||||
with:
|
|
||||||
name: "Build #${{ env.BUILD_NUMBER }} for ${{ env.VERSION }}"
|
|
||||||
tag_name: "build/${{ env.VERSION }}/${{ env.BUILD_NUMBER }}"
|
|
||||||
target_commitish: ${{ github.ref_name }}
|
|
||||||
generate_release_notes: true
|
|
||||||
fail_on_unmatched_files: true
|
|
||||||
files: build/libs/*.jar
|
|
||||||
|
|
||||||
- name: Release Artifacts (Latest/Stable)
|
|
||||||
if: startsWith(github.ref_name, 'ver/')
|
|
||||||
uses: softprops/action-gh-release@v0.1.15
|
|
||||||
with:
|
|
||||||
name: "Build #${{ env.BUILD_NUMBER }} for ${{ env.VERSION }}"
|
|
||||||
tag_name: "build/${{ github.ref_name }}/latest"
|
|
||||||
target_commitish: ${{ github.ref_name }}
|
|
||||||
generate_release_notes: true
|
|
||||||
fail_on_unmatched_files: true
|
|
||||||
files: build/libs/*.jar
|
|
||||||
|
|
||||||
- name: Release Artifacts (Latest/Development)
|
|
||||||
if: startsWith(github.ref_name, 'dev/')
|
|
||||||
uses: softprops/action-gh-release@v0.1.15
|
|
||||||
with:
|
|
||||||
name: "Development Build for ${{ env.VERSION }}"
|
|
||||||
tag_name: build/${{ env.VERSION }}/latest
|
|
||||||
target_commitish: ${{ github.ref_name }}
|
|
||||||
generate_release_notes: true
|
|
||||||
fail_on_unmatched_files: true
|
|
||||||
files: build/libs/*.jar
|
|
||||||
241
.gitignore
vendored
241
.gitignore
vendored
@@ -1,60 +1,211 @@
|
|||||||
# JVM crash related
|
# Generated from https://gitignore.io/
|
||||||
core.*
|
|
||||||
|
### Paperweight ###
|
||||||
|
run/
|
||||||
|
paper-api/
|
||||||
|
paper-server/
|
||||||
|
purpur-api/
|
||||||
|
purpur-server/
|
||||||
|
plazma-api/build.gradle.kts
|
||||||
|
plazma-server/build.gradle.kts
|
||||||
|
plazma-server/src/minecraft/
|
||||||
|
|
||||||
|
### Git ###
|
||||||
|
# Created by git when using merge tools for conflicts
|
||||||
|
*.orig
|
||||||
|
*.BACKUP.*
|
||||||
|
*.BASE.*
|
||||||
|
*.LOCAL.*
|
||||||
|
*.REMOTE.*
|
||||||
|
*_BACKUP_*.txt
|
||||||
|
*_BASE_*.txt
|
||||||
|
*_LOCAL_*.txt
|
||||||
|
*_REMOTE_*.txt
|
||||||
|
|
||||||
|
### Java ###
|
||||||
|
*.class
|
||||||
|
*.log
|
||||||
|
*.jar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
replay_pid*
|
||||||
|
|
||||||
# Intellij
|
# Kotlin DSL
|
||||||
.idea/
|
.kotlin/
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
out/
|
|
||||||
|
|
||||||
# Eclipse
|
### Gradle ###
|
||||||
.classpath
|
|
||||||
.project
|
|
||||||
.settings/
|
|
||||||
|
|
||||||
# netbeans
|
|
||||||
nbproject/
|
|
||||||
nbactions.xml
|
|
||||||
|
|
||||||
# Gradle
|
|
||||||
!gradle-wrapper.jar
|
|
||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
*/build/
|
|
||||||
run/
|
|
||||||
javadoc/
|
|
||||||
|
|
||||||
# we use maven!
|
# Avoid ignore Gradle wrappper properties
|
||||||
build.xml
|
!gradle-wrapper.jar
|
||||||
|
!gradle-wrapper.properties
|
||||||
|
|
||||||
# Maven
|
# Cache of project
|
||||||
log/
|
.gradletasknamecache
|
||||||
target/
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
|
|
||||||
# various other potential build files
|
# Java heap dump
|
||||||
|
*.hprof
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
bin/
|
bin/
|
||||||
|
tmp/
|
||||||
|
.project/
|
||||||
|
.metadata/
|
||||||
|
.settings/
|
||||||
|
.loadpath/
|
||||||
|
.recommenders/
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# JDT-specific (Eclipse Java Development Tools)
|
||||||
|
.classpath
|
||||||
|
|
||||||
|
# Java annotation processor (APT)
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
# Annotation Processing
|
||||||
|
.apt_generated/
|
||||||
|
.apt_generated_test/
|
||||||
|
|
||||||
|
### JetBrains ###
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# Ignore everything but code style settings and run configurations
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
!.idea/codeStyles
|
||||||
|
!.idea/runConfigurations
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Fleet
|
||||||
|
.fleet/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
**/nbproject/private/
|
||||||
|
**/nbproject/Makefile-*.mk
|
||||||
|
**/nbproject/Package-*.bash
|
||||||
|
nbbuild/
|
||||||
dist/
|
dist/
|
||||||
manifest.mf
|
nbdist/
|
||||||
|
.nb-gradle/
|
||||||
|
|
||||||
# Mac
|
### Vim ###
|
||||||
.DS_Store/
|
# Swap
|
||||||
.DS_Store
|
[._]*.s[a-v][a-z]
|
||||||
|
[._]*.sw[a-p]
|
||||||
|
[._]s[a-rt-v][a-z]
|
||||||
|
[._]ss[a-gi-z]
|
||||||
|
[._]sw[a-p]
|
||||||
|
|
||||||
# vim
|
# Session
|
||||||
.*.sw[a-p]
|
Session.vim
|
||||||
|
Sessionx.vim
|
||||||
|
|
||||||
# Linux temp files
|
# Temporary
|
||||||
|
.netrwhist
|
||||||
|
|
||||||
|
# Auto-generated tag files
|
||||||
|
tags
|
||||||
|
|
||||||
|
# Persistent undo
|
||||||
|
[._]*.un~
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
.ionide
|
||||||
|
|
||||||
|
### Linux ###
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# Paperweight
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
build-data/
|
.fuse_hidden*
|
||||||
*-API
|
|
||||||
*-MojangAPI
|
# KDE directory preferences
|
||||||
*-Server
|
.directory
|
||||||
paper-api-generator
|
|
||||||
compare.txt
|
# Linux trash folder which might appear on any partition or disk
|
||||||
*.patch
|
.Trash-*
|
||||||
!patches/**/*
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
### macOS ###
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# iCloud generated files
|
||||||
|
*.icloud
|
||||||
|
|
||||||
|
### Windows ###
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|||||||
23
LICENSE.md
23
LICENSE.md
@@ -1,23 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
=====================
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
|
||||||
obtaining a copy of this software and associated documentation
|
|
||||||
files (the “Software”), to deal in the Software without
|
|
||||||
restriction, including without limitation the rights to use,
|
|
||||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
24
README.md
24
README.md
@@ -1,24 +0,0 @@
|
|||||||
<div align="center">
|
|
||||||
|
|
||||||
[](https://github.com/PlazmaMC/Plazma)
|
|
||||||
|
|
||||||
### A Server Platform for Minecraft: Java Edition based on [Paper](https://github.com/PaperMC/Paper)
|
|
||||||
|
|
||||||
[](https://plazmamc.org/discord)
|
|
||||||
[](LICENSE.md)
|
|
||||||
[](https://plazmamc.org/downloads)
|
|
||||||
|
|
||||||
[](https://plazmamc.org/downloads)
|
|
||||||
[](https://github.com/PlazmaMC/Plazma/stargazers)
|
|
||||||
[](https://github.com/PlazmaMC/Plazma/forks)
|
|
||||||
[](https://github.com/PlazmaMC/Plazma/watchers)
|
|
||||||
|
|
||||||
### [⬇️ Downloads](https://plazmamc.org/downloads)
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
[main]: https://github.com/PlazmaMC/Plazma
|
|
||||||
|
|
||||||
> [!IMPORTANT]
|
|
||||||
This is the branch for Plazma 1.21.2/3. If you want to know more about Plazma, please check the **[main branch][main]**.<br>
|
|
||||||
이곳은 플라즈마의 1.21.2/3용 분기입니다. 플라즈마에 대해 자세히 알고 싶다면 **[main 분기][main]** 를 확인해주세요.
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# You can use this file to import files from minecraft libraries into the project
|
|
||||||
# format:
|
|
||||||
# <artifactId> <fileName>
|
|
||||||
# both fully qualified and a file based syntax are accepted for <fileName>:
|
|
||||||
# authlib com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
|
|
||||||
# datafixerupper com.mojang.datafixers.DataFixerBuilder
|
|
||||||
# datafixerupper com/mojang/datafixers/util/Either.java
|
|
||||||
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
|
|
||||||
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
|
|
||||||
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
|
|
||||||
# To import minecraft data files, like the default chat type, use `mc_data` as the prefix:
|
|
||||||
# mc_data chat_type/chat.json
|
|
||||||
# mc_data dimension_type/overworld.json
|
|
||||||
#
|
|
||||||
204
build.gradle.kts
204
build.gradle.kts
@@ -2,172 +2,84 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
|||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
id("io.papermc.paperweight.patcher") version "2.0.0-beta.14"
|
||||||
`maven-publish`
|
|
||||||
`kotlin-dsl`
|
|
||||||
`always-up-to-date`
|
|
||||||
alias(libs.plugins.shadow) apply false
|
|
||||||
alias(libs.plugins.paperweight)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val jdkVersion = property("jdkVersion").toString().toInt()
|
paperweight {
|
||||||
val providerRepo = property("providerRepo").toString()
|
upstreams.register("purpur") {
|
||||||
val brandName = property("brandName").toString()
|
repo = github("PurpurMC", "Purpur")
|
||||||
|
ref = providers.gradleProperty("purpurRef")
|
||||||
|
|
||||||
kotlin.jvmToolchain(jdkVersion)
|
patchFile {
|
||||||
|
path = "purpur-server/build.gradle.kts"
|
||||||
repositories {
|
outputFile = file("plazma-server/build.gradle.kts")
|
||||||
mavenCentral()
|
patchFile = file("plazma-server/build.gradle.kts.patch")
|
||||||
maven("https://repo.papermc.io/repository/maven-public/") {
|
}
|
||||||
content { onlyForConfigurations(configurations.paperclip.name) }
|
patchFile {
|
||||||
}
|
path = "purpur-api/build.gradle.kts"
|
||||||
}
|
outputFile = file("plazma-api/build.gradle.kts")
|
||||||
|
patchFile = file("plazma-api/build.gradle.kts.patch")
|
||||||
dependencies {
|
}
|
||||||
remapper(libs.remapper)
|
patchRepo("paperApi") {
|
||||||
decompiler(libs.decompiler)
|
upstreamPath = "paper-api"
|
||||||
paperclip(libs.paperclip)
|
patchesDir = file("plazma-api/paper-patches")
|
||||||
}
|
outputDir = file("paper-api")
|
||||||
|
}
|
||||||
allprojects {
|
patchDir("purpurApi") {
|
||||||
apply(plugin = "java")
|
upstreamPath = "purpur-api"
|
||||||
apply(plugin = "maven-publish")
|
excludes = listOf("build.gradle.kts", "build.gradle.kts.patch", "paper-patches")
|
||||||
|
patchesDir = file("plazma-api/purpur-patches")
|
||||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(jdkVersion))
|
outputDir = file("purpur-api")
|
||||||
|
|
||||||
publishing.repositories.maven("https://maven.pkg.github.com/$providerRepo") {
|
|
||||||
name = "githubPackage"
|
|
||||||
url = uri("https://maven.pkg.github.com/$providerRepo")
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
username = System.getenv("GITHUB_USERNAME")
|
|
||||||
password = System.getenv("GITHUB_TOKEN")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
tasks {
|
apply(plugin = "java-library")
|
||||||
withType<JavaCompile>().configureEach {
|
apply(plugin = "maven-publish")
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release = jdkVersion
|
|
||||||
options.compilerArgs.addAll(listOf(
|
|
||||||
"--add-modules=jdk.incubator.vector",
|
|
||||||
"-Xmaxwarns", "1"
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
withType<Javadoc> {
|
extensions.configure<JavaPluginExtension> {
|
||||||
options.encoding = Charsets.UTF_8.name()
|
toolchain {
|
||||||
}
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
|
||||||
withType<ProcessResources> {
|
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
|
|
||||||
withType<Test> {
|
|
||||||
testLogging {
|
|
||||||
showStackTraces = true
|
|
||||||
exceptionFormat = TestExceptionFormat.FULL
|
|
||||||
events(TestLogEvent.STANDARD_OUT)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven("https://jitpack.io")
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
maven("https://papermc.io/repo/repository/maven-public/")
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
paperweight {
|
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||||
serverProject = project(":${brandName.lowercase()}-server")
|
isPreserveFileTimestamps = false
|
||||||
|
isReproducibleFileOrder = true
|
||||||
remapRepo = "https://repo.papermc.io/repository/maven-public/"
|
}
|
||||||
decompileRepo = "https://repo.papermc.io/repository/maven-public/"
|
tasks.withType<JavaCompile> {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
usePaperUpstream(providers.gradleProperty("paperCommit")) {
|
options.release = 21
|
||||||
withPaperPatcher {
|
options.isFork = true
|
||||||
apiPatchDir.set(projectDir.resolve("patches/api"))
|
}
|
||||||
apiOutputDir.set(projectDir.resolve("$brandName-API"))
|
tasks.withType<Javadoc> {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
serverPatchDir.set(projectDir.resolve("patches/server"))
|
}
|
||||||
serverOutputDir.set(projectDir.resolve("$brandName-Server"))
|
tasks.withType<ProcessResources> {
|
||||||
}
|
filteringCharset = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
patchTasks.register("generatedApi") {
|
tasks.withType<Test> {
|
||||||
isBareDirectory = true
|
testLogging {
|
||||||
upstreamDirPath = "paper-api-generator/generated"
|
showStackTraces = true
|
||||||
patchDir = projectDir.resolve("patches/generated-api")
|
exceptionFormat = TestExceptionFormat.FULL
|
||||||
outputDir = projectDir.resolve("paper-api-generator/generated")
|
events(TestLogEvent.STANDARD_OUT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val paperRepoVal = property("paperRepo").toString()
|
extensions.configure<PublishingExtension> {
|
||||||
val paperBranch = property("paperBranch").toString()
|
repositories {
|
||||||
val purpurRepoVal = property("purpurRepo").toString()
|
/*
|
||||||
val purpurBranch = property("purpurBranch").toString()
|
maven("https://repo.papermc.io/repository/maven-snapshots/") {
|
||||||
val pufferfishRepoVal = property("pufferfishRepo").toString()
|
name = "paperSnapshots"
|
||||||
val pufferfishBranch = property("pufferfishBranch").toString()
|
credentials(PasswordCredentials::class)
|
||||||
val isUsePufferfish = property("usePufferfish").toString().toBoolean()
|
|
||||||
|
|
||||||
alwaysUpToDate {
|
|
||||||
|
|
||||||
paperRepo.set(paperRepoVal)
|
|
||||||
paperRef.set(paperBranch)
|
|
||||||
paperCommitName.set("paperCommit")
|
|
||||||
|
|
||||||
purpurRepo.set(purpurRepoVal)
|
|
||||||
purpurRef.set(purpurBranch)
|
|
||||||
purpurCommitName.set("purpurCommit")
|
|
||||||
|
|
||||||
pufferfishRepo.set(pufferfishRepoVal)
|
|
||||||
pufferfishRef.set(pufferfishBranch)
|
|
||||||
usePufferfish.set(isUsePufferfish)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
applyPatches {
|
|
||||||
dependsOn("applyGeneratedApiPatches")
|
|
||||||
}
|
|
||||||
|
|
||||||
rebuildPatches {
|
|
||||||
dependsOn("rebuildGeneratedApiPatches")
|
|
||||||
}
|
|
||||||
|
|
||||||
generateDevelopmentBundle {
|
|
||||||
apiCoordinates.set("${project.group}:${brandName.lowercase()}-api")
|
|
||||||
libraryRepositories.addAll(
|
|
||||||
"https://repo.maven.apache.org/maven2/",
|
|
||||||
"https://maven.pkg.github.com/$providerRepo",
|
|
||||||
"https://papermc.io/repo/repository/maven-public/"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
clean {
|
|
||||||
doLast {
|
|
||||||
listOf(
|
|
||||||
".gradle/caches",
|
|
||||||
"$brandName-API",
|
|
||||||
"$brandName-Server",
|
|
||||||
"paper-api-generator",
|
|
||||||
"run",
|
|
||||||
|
|
||||||
// remove dev environment files
|
|
||||||
"0001-fixup.patch",
|
|
||||||
"compare.txt"
|
|
||||||
).forEach {
|
|
||||||
projectDir.resolve(it).deleteRecursively()
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications.create<MavenPublication>("devBundle") {
|
|
||||||
artifact(tasks.generateDevelopmentBundle) { artifactId = "dev-bundle" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
plugins {
|
|
||||||
java
|
|
||||||
`kotlin-dsl`
|
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven("https://papermc.io/repo/repository/maven-public/")
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin.jvmToolchain {
|
|
||||||
languageVersion = JavaLanguageVersion.of(17)
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
shadow("io.papermc.paperweight:paperweight-patcher:1.6.2-SNAPSHOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
jar {
|
|
||||||
finalizedBy(shadowJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
archiveFileName.set("buildSrc.jar")
|
|
||||||
configurations = listOf(project.configurations["shadow"])
|
|
||||||
|
|
||||||
exclude("META-INF/gradle-plugins/io.papermc.paperweight.patcher.properties")
|
|
||||||
relocate("io.papermc.paperweight", "org.plazmamc.alwaysuptodate.internal.paperweight")
|
|
||||||
minimize()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate
|
|
||||||
|
|
||||||
import io.papermc.paperweight.util.Git
|
|
||||||
import org.gradle.api.Plugin
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.TaskProvider
|
|
||||||
import org.plazmamc.alwaysuptodate.tasks.*
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.CheckGitTask
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.configureTask
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.flatten
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.registerTask
|
|
||||||
|
|
||||||
class AlwaysUpToDate : Plugin<Project> {
|
|
||||||
|
|
||||||
@Suppress("UNUSED_VARIABLE")
|
|
||||||
override fun apply(target: Project): Unit = with(target) {
|
|
||||||
|
|
||||||
Git.checkForGit()
|
|
||||||
|
|
||||||
val extension = extensions.create("alwaysUpToDate", AlwaysUpToDateExtension::class.java)
|
|
||||||
|
|
||||||
val git = configureTask<CheckGitTask>("checkGitStatus", "Verify that Git is available")
|
|
||||||
|
|
||||||
fun generateTasks(
|
|
||||||
upstream: String,
|
|
||||||
provider: AlwaysUpToDateExtension.() -> Pair<Pair<Property<String>, Property<String>>, Property<String>>
|
|
||||||
): Triple<TaskProvider<CheckUpstreamCommit>, TaskProvider<CreateCompareComment>, TaskProvider<CreateCompareComment>> {
|
|
||||||
val i = registerTask<CheckUpstreamCommit>("check$upstream", "Check if the $upstream commit is up to date") {
|
|
||||||
dependsOn(git)
|
|
||||||
val (repo, ref, commitProperty) = extension.provider().flatten()
|
|
||||||
this.repo.set(repo)
|
|
||||||
this.ref.set(ref)
|
|
||||||
this.commitPropertyName.set(commitProperty)
|
|
||||||
}
|
|
||||||
|
|
||||||
val j = registerTask<CreateCompareComment>("compare$upstream", "Create a comment comparing the $upstream commit") {
|
|
||||||
dependsOn(git)
|
|
||||||
val (repo, ref, commitProperty) = extension.provider().flatten()
|
|
||||||
this.repo.set(repo)
|
|
||||||
this.ref.set(ref)
|
|
||||||
this.commitPropertyName.set(commitProperty)
|
|
||||||
this.clear.set(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
val k = registerTask<CreateCompareComment>(
|
|
||||||
"cleanCompare$upstream",
|
|
||||||
"Create a comment comparing the $upstream commit"
|
|
||||||
) {
|
|
||||||
dependsOn(git)
|
|
||||||
val (repo, ref, commitProperty) = extension.provider().flatten()
|
|
||||||
this.repo.set(repo)
|
|
||||||
this.ref.set(ref)
|
|
||||||
this.commitPropertyName.set(commitProperty)
|
|
||||||
this.clear.set(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (i to j to k).flatten()
|
|
||||||
}
|
|
||||||
|
|
||||||
val (checkPaper, comparePaper, cleanComparePaper) = generateTasks("Paper") { paperRepo to paperRef to paperCommitName }
|
|
||||||
val (checkPurpur, comparePurpur, cleanComparePurpur) = generateTasks("Purpur") { purpurRepo to purpurRef to purpurCommitName }
|
|
||||||
|
|
||||||
registerTask<SimpleUpstreamUpdateTask>("updateUpstream", "Update the upstream commit") {
|
|
||||||
dependsOn(git)
|
|
||||||
repo.convention(extension.paperRepo)
|
|
||||||
ref.convention(extension.paperRef)
|
|
||||||
workDir.set(layout.projectDirectory)
|
|
||||||
regex.convention("paperCommit = ")
|
|
||||||
}
|
|
||||||
|
|
||||||
registerTask<PurpurUpdateTask>("updateImplementation", "Update the implementation") {
|
|
||||||
dependsOn(git)
|
|
||||||
workDir.set(layout.projectDirectory)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate
|
|
||||||
|
|
||||||
class AlwaysUpToDateException : Exception {
|
|
||||||
constructor(message: String) : super(message)
|
|
||||||
constructor(message: String, cause: Throwable?) : super(message, cause)
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate
|
|
||||||
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
|
|
||||||
interface AlwaysUpToDateExtension {
|
|
||||||
|
|
||||||
val paperRepo: Property<String>
|
|
||||||
val paperRef: Property<String>
|
|
||||||
|
|
||||||
val purpurRepo: Property<String>
|
|
||||||
val purpurRef: Property<String>
|
|
||||||
|
|
||||||
val pufferfishRepo: Property<String>
|
|
||||||
val pufferfishRef: Property<String>
|
|
||||||
val usePufferfish: Property<Boolean>
|
|
||||||
|
|
||||||
val paperCommitName: Property<String>
|
|
||||||
val purpurCommitName: Property<String>
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.plazmamc.alwaysuptodate.AlwaysUpToDateException
|
|
||||||
import org.plazmamc.alwaysuptodate.AlwaysUpToDateExtension
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.extension
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.flatten
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.git
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.property
|
|
||||||
|
|
||||||
abstract class CheckUpstreamCommit : Task() {
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val repo: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val ref: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val commitPropertyName: Property<String>
|
|
||||||
|
|
||||||
override fun init(): Unit = with(project) {
|
|
||||||
outputs.upToDateWhen { checkCommitFor { repo to ref to commitPropertyName } }
|
|
||||||
|
|
||||||
doLast {
|
|
||||||
println(checkCommitFor { repo to ref to commitPropertyName })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Project.getLatest(repository: String, branch: String) =
|
|
||||||
git("ls-remote", repository).readText()?.lines()
|
|
||||||
?.first("[a-z0-9]{40}\trefs/heads/$branch".toRegex()::matches)?.split("\t")?.first()
|
|
||||||
?: throw AlwaysUpToDateException("Failed to get latest commit of $repository")
|
|
||||||
|
|
||||||
fun Project.checkCommitFor(block: AlwaysUpToDateExtension.() -> Pair<Pair<Property<String>, Property<String>>, Property<String>>): Boolean =
|
|
||||||
extension.block().flatten().let { getLatest(extension { it.first }, extension { it.second }) == property { it.third } }
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.tasks
|
|
||||||
|
|
||||||
import io.papermc.paperweight.util.fromJson
|
|
||||||
import io.papermc.paperweight.util.gson
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.property
|
|
||||||
import paper.libs.com.google.gson.JsonObject
|
|
||||||
import java.net.URI
|
|
||||||
|
|
||||||
abstract class CreateCompareComment : Task() {
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val clear: Property<Boolean>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val repo: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val ref: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val commitPropertyName: Property<String>
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun create() = with(project) {
|
|
||||||
val builder = StringBuilder()
|
|
||||||
val rawRepo = URI.create(repo.get()).path.substring(1)
|
|
||||||
|
|
||||||
if (clear.get() || !file("compare.txt").exists())
|
|
||||||
builder.append("\n\nUpstream has released updates that appear to apply and compile correctly.")
|
|
||||||
else
|
|
||||||
builder.append(file("compare.txt").readText())
|
|
||||||
|
|
||||||
builder.append("\n\n[${rawRepo.split("/").last()} Changes]\n")
|
|
||||||
|
|
||||||
gson.fromJson<JsonObject>(
|
|
||||||
URI.create("https://api.github.com/repos/$rawRepo/compare/${property { commitPropertyName }}...${ref.get()}").toURL().readText()
|
|
||||||
)["commits"].asJsonArray.forEach { obj ->
|
|
||||||
obj.asJsonObject.let {
|
|
||||||
builder.append("$rawRepo@${it["sha"].asString.subSequence(0, 7)}: ${it["commit"].asJsonObject["message"].asString.split("\n")[0]}\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file("compare.txt").writeText(builder.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.tasks
|
|
||||||
|
|
||||||
import io.papermc.paperweight.util.Git
|
|
||||||
import io.papermc.paperweight.util.path
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.InputDirectory
|
|
||||||
import org.gradle.api.tasks.Internal
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.addCommit
|
|
||||||
|
|
||||||
abstract class GenerateMergedAPIPatch : Task() {
|
|
||||||
|
|
||||||
@get:InputDirectory
|
|
||||||
abstract val inputDir: DirectoryProperty
|
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
abstract val workDir: DirectoryProperty
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val commitTitle: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val author: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val license: Property<String>
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun generate() = with(workDir.path) {
|
|
||||||
val dotGit = resolve(".git").toFile().also(java.io.File::deleteRecursively)
|
|
||||||
|
|
||||||
inputDir.path.toFile().copyRecursively(dotGit, overwrite = true)
|
|
||||||
Git(this).addCommit("${commitTitle.get()}\n\n${license.get()}", "--author=${author.get()}")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.tasks
|
|
||||||
|
|
||||||
import io.papermc.paperweight.util.Git
|
|
||||||
import io.papermc.paperweight.util.path
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.Internal
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.addCommit
|
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Path
|
|
||||||
|
|
||||||
abstract class GenerateMergedServerPatch : Task() {
|
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
abstract val workDir: DirectoryProperty
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val commitTitle: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val author: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val license: Property<String>
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun generate() = with(workDir.path) {
|
|
||||||
val dotGit = resolve(".git").toFile().also(java.io.File::deleteRecursively)
|
|
||||||
|
|
||||||
copySource(this)
|
|
||||||
|
|
||||||
val paper = resolve("../.gradle/caches/paperweight/upstreams/paper/Paper-Server")
|
|
||||||
copySource(paper)
|
|
||||||
|
|
||||||
Git(paper).addCommit("Vanilla Sources", "--author=Automated <auto@mated.null>")
|
|
||||||
|
|
||||||
paper.resolve(".git").toFile().copyRecursively(dotGit, overwrite = true)
|
|
||||||
Git(this).addCommit("${commitTitle.get()}\n\n${license.get()}", "--author=${author.get()}")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun copySource(dir: Path) = with(dir.resolve(".gradle/caches/paperweight/mc-dev-sources")) {
|
|
||||||
val target = dir.resolve("src/main")
|
|
||||||
resolve("net").toFile().copyRecursively(target.resolve("java/net").toFile(), overwrite = true)
|
|
||||||
resolve("com").toFile().copyRecursively(target.resolve("java/com").toFile(), overwrite = true)
|
|
||||||
resolve("data").toFile().copyRecursively(target.resolve("resources/data").toFile(), overwrite = true)
|
|
||||||
resolve("assets").toFile().copyRecursively(target.resolve("resources/assets").toFile(), overwrite = true)
|
|
||||||
}
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.tasks
|
|
||||||
|
|
||||||
import io.papermc.paperweight.patcher.tasks.CheckoutRepo
|
|
||||||
import io.papermc.paperweight.util.Git
|
|
||||||
import io.papermc.paperweight.util.cache
|
|
||||||
import io.papermc.paperweight.util.path
|
|
||||||
import io.papermc.paperweight.util.set
|
|
||||||
import org.gradle.api.file.Directory
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.provider.Provider
|
|
||||||
import org.gradle.api.tasks.Internal
|
|
||||||
import org.gradle.api.tasks.OutputDirectory
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.gradle.api.tasks.TaskProvider
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.*
|
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Path
|
|
||||||
import java.util.*
|
|
||||||
import kotlin.io.path.ExperimentalPathApi
|
|
||||||
import kotlin.io.path.name
|
|
||||||
import kotlin.io.path.walk
|
|
||||||
|
|
||||||
@Deprecated("It will soon be changed to be available for other upstreams.")
|
|
||||||
abstract class PurpurUpdateTask : Task() {
|
|
||||||
|
|
||||||
private val pufferfishHeader = """
|
|
||||||
Pufferfish
|
|
||||||
Copyright (C) ${Calendar.getInstance().get(Calendar.YEAR)} Pufferfish Studios LLC
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
""".trimIndent()
|
|
||||||
private val pufferfishAuthor = "Kevin Raneri <kevin.raneri@gmail.com>"
|
|
||||||
private val purpurHeader = """
|
|
||||||
PurpurMC
|
|
||||||
Copyright (C) ${Calendar.getInstance().get(Calendar.YEAR)} PurpurMC
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
""".trimIndent()
|
|
||||||
private val purpurAuthor = "granny <contact@granny.dev>"
|
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
abstract val workDir: DirectoryProperty
|
|
||||||
|
|
||||||
@get:OutputDirectory
|
|
||||||
abstract val purpurDir: DirectoryProperty
|
|
||||||
|
|
||||||
@get:OutputDirectory
|
|
||||||
abstract val pufferfishDir: DirectoryProperty
|
|
||||||
|
|
||||||
override fun init(): Unit = with(project) {
|
|
||||||
val wd = layout.cache.resolve("alwaysUpToDate/update/purpur").also { it.toFile().deleteRecursively() }
|
|
||||||
workDir.set(wd)
|
|
||||||
|
|
||||||
val compare =
|
|
||||||
configureTask<CreateCompareComment>("createPurpurCompareComment", "Create Purpur Compare Comment") {
|
|
||||||
clear.convention(true)
|
|
||||||
repo.convention(extension.purpurRepo)
|
|
||||||
ref.convention(extension.purpurRef)
|
|
||||||
commitPropertyName.convention(extension.purpurCommitName)
|
|
||||||
}
|
|
||||||
|
|
||||||
val paper = dependsOn<SimpleUpstreamUpdateTask>("updatePaper", "Update Paper") {
|
|
||||||
outputs.upToDateWhen { checkCommitFor { repo to ref to paperCommitName } }
|
|
||||||
dependsOn(compare)
|
|
||||||
repo.convention(extension.paperRepo)
|
|
||||||
ref.convention(extension.paperRef)
|
|
||||||
regex.convention("paperCommit = ")
|
|
||||||
workDir.set(layout.projectDirectory)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun checkout(
|
|
||||||
name: String, repo: Provider<String>, ref: Provider<String>, regex: String, block: CheckoutRepo.() -> Unit
|
|
||||||
): Pair<TaskProvider<out Task>, Directory> {
|
|
||||||
val updatePaper = configureTask<SimpleUpstreamUpdateTask>("update${name}Paper", "Update $name's Paper") {
|
|
||||||
this.repo.convention(extension.paperRepo)
|
|
||||||
this.ref.convention(extension.paperRef)
|
|
||||||
this.regex.convention(regex)
|
|
||||||
this.workDir.set(wd.resolve(name))
|
|
||||||
}
|
|
||||||
|
|
||||||
val checkout = dependsOn<CheckoutRepo>("checkout$name", "Checkout $name") {
|
|
||||||
this.dependsOn(paper)
|
|
||||||
this.repoName.convention(name)
|
|
||||||
this.url.convention(repo)
|
|
||||||
this.ref.convention(ref)
|
|
||||||
this.workDir.set(wd)
|
|
||||||
|
|
||||||
this.block()
|
|
||||||
this.finalizedBy(updatePaper)
|
|
||||||
}
|
|
||||||
|
|
||||||
return updatePaper to checkout.flatMap { it.outputDir }.get()
|
|
||||||
}
|
|
||||||
|
|
||||||
val (checkoutPufferfish, pufferfish) =
|
|
||||||
checkout("Pufferfish", extension.pufferfishRepo, extension.pufferfishRef, "paperRef=") {
|
|
||||||
onlyIf { extension { usePufferfish } }
|
|
||||||
}
|
|
||||||
val (checkoutPurpur, purpur) =
|
|
||||||
checkout("Purpur", extension.purpurRepo, extension.purpurRef, "paperCommit = ") {
|
|
||||||
dependsOn(checkoutPufferfish)
|
|
||||||
}
|
|
||||||
|
|
||||||
pufferfishDir.set(pufferfish)
|
|
||||||
purpurDir.set(purpur)
|
|
||||||
|
|
||||||
val preparePurpur = configureTask("preparePurpur", "Prepare Purpur Sources") {
|
|
||||||
mustRunAfter(paper)
|
|
||||||
dependsOn(checkoutPurpur)
|
|
||||||
doLast { Gradle(purpur.path)("applyPatches").executeOut() }
|
|
||||||
}
|
|
||||||
val preparePufferfish = configureTask("preparePufferfish", "Prepare Pufferfish Sources") {
|
|
||||||
onlyIf { extension { usePufferfish } }
|
|
||||||
mustRunAfter(paper)
|
|
||||||
dependsOn(checkoutPurpur, checkoutPufferfish)
|
|
||||||
doLast {
|
|
||||||
val base = pufferfish.path.resolve("patches").also { it.toFile().deleteRecursively() }
|
|
||||||
val source = purpur.path.resolve("patches")
|
|
||||||
source.resolve("server").copyPatch(base.resolve("server"), "Pufferfish-Server-Changes")
|
|
||||||
source.resolve("api").copyPatch(base.resolve("api"), "Pufferfish-API-Changes")
|
|
||||||
Gradle(pufferfish.path)("applyPatches").executeOut()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependsOn(preparePurpur, preparePufferfish)
|
|
||||||
|
|
||||||
val serverPatch =
|
|
||||||
configureTask<GenerateMergedServerPatch>("generateMergedServerPatches", "Generate Merged Server Patch") {
|
|
||||||
dependsOn(preparePurpur)
|
|
||||||
if (!extension { usePufferfish }) {
|
|
||||||
workDir.convention(purpur.dir("Purpur-Server"))
|
|
||||||
commitTitle.convention("Purpur Server Changes")
|
|
||||||
license.convention(purpurHeader)
|
|
||||||
author.convention(purpurAuthor)
|
|
||||||
return@configureTask
|
|
||||||
}
|
|
||||||
|
|
||||||
dependsOn(preparePufferfish)
|
|
||||||
workDir.convention(pufferfish.dir("pufferfish-server"))
|
|
||||||
commitTitle.convention("Pufferfish Server Changes")
|
|
||||||
license.convention(pufferfishHeader)
|
|
||||||
author.convention(pufferfishAuthor)
|
|
||||||
|
|
||||||
doLast {
|
|
||||||
val dotGit = pufferfish.dir("pufferfish-server/.git").path.toFile()
|
|
||||||
|
|
||||||
purpur.path.resolve("Purpur-Server").let {
|
|
||||||
val purpurDotGit = it.resolve(".git").toFile().also(File::deleteRecursively)
|
|
||||||
|
|
||||||
copySource(it)
|
|
||||||
dotGit.copyRecursively(purpurDotGit, overwrite = true)
|
|
||||||
Git(it).addCommit("Purpur Server Changes\n\n$purpurHeader", "--author=$purpurAuthor")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val pufferfishAPIChanges = configureTask<GenerateMergedAPIPatch>(
|
|
||||||
"generateMergedPufferfishAPIPatch",
|
|
||||||
"Generate Merged Pufferfish API Patch"
|
|
||||||
) {
|
|
||||||
dependsOn(preparePufferfish)
|
|
||||||
inputDir.convention(pufferfish.dir(".gradle/caches/paperweight/upstreams/paper/Paper-API/.git"))
|
|
||||||
workDir.convention(pufferfish.dir("pufferfish-api"))
|
|
||||||
commitTitle.convention("Pufferfish API Changes")
|
|
||||||
license.convention(pufferfishHeader)
|
|
||||||
author.convention(pufferfishAuthor)
|
|
||||||
}
|
|
||||||
|
|
||||||
val apiPatch = configureTask<GenerateMergedAPIPatch>(
|
|
||||||
"generateMergedAPIPatches",
|
|
||||||
"Generate Merged API Patches"
|
|
||||||
) {
|
|
||||||
dependsOn(preparePurpur)
|
|
||||||
if (extension { usePufferfish }) dependsOn(pufferfishAPIChanges)
|
|
||||||
|
|
||||||
workDir.convention(purpur.dir("Purpur-API"))
|
|
||||||
commitTitle.convention("Purpur API Changes")
|
|
||||||
license.convention(purpurHeader)
|
|
||||||
author.convention(purpurAuthor)
|
|
||||||
inputDir.convention(
|
|
||||||
if (extension { usePufferfish }) pufferfish.dir("pufferfish-api/.git")
|
|
||||||
else purpur.dir(".gradle/caches/paperweight/upstreams/paper/Paper-API/.git")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
dependsOn("buildPatches", "Build Merged Patches") {
|
|
||||||
dependsOn(serverPatch, apiPatch)
|
|
||||||
doLast { Gradle(purpur.path)("rebuildPatches").executeOut() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun update() = with(project) {
|
|
||||||
val purpur = purpurDir.path
|
|
||||||
val pufferfish = if (extension { usePufferfish }) pufferfishDir.path else null
|
|
||||||
|
|
||||||
val patches = purpur.resolve("patches")
|
|
||||||
with(layout.projectDirectory.path.resolve("patches")) {
|
|
||||||
patches.resolve("server").copyPatch( resolve("server"),
|
|
||||||
if (pufferfish == null) "" else "Pufferfish-Server-Changes",
|
|
||||||
"Purpur-Server-Changes"
|
|
||||||
)
|
|
||||||
|
|
||||||
patches.resolve("api").copyPatch( resolve("api"),
|
|
||||||
if (pufferfish == null) "" else "Pufferfish-API-Changes",
|
|
||||||
"Purpur-API-Changes"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
file("gradle.properties").let {
|
|
||||||
it.writeText(
|
|
||||||
it.readText().replace("purpurCommit = .*".toRegex(), "purpurCommit = ${Git(purpur).revParse()}")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalPathApi::class)
|
|
||||||
private fun Path.copyPatch(to: Path, vararg name: String) = walk().sorted()
|
|
||||||
.filter { entry -> name.any { entry.name.endsWith("$it.patch") } }.map(Path::toFile)
|
|
||||||
.forEachIndexed { count, patch ->
|
|
||||||
patch.copyTo(
|
|
||||||
to.resolve("${count + 1}".padStart(4, '0') + "-" + name.first { patch.name.substring(5) == "$it.patch" } + ".patch").toFile(),
|
|
||||||
overwrite = true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.tasks
|
|
||||||
|
|
||||||
import io.papermc.paperweight.util.Git
|
|
||||||
import io.papermc.paperweight.util.path
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.InputDirectory
|
|
||||||
import org.gradle.api.tasks.Optional
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.plazmamc.alwaysuptodate.AlwaysUpToDateException
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.dependsOn
|
|
||||||
import org.plazmamc.alwaysuptodate.utils.extension
|
|
||||||
|
|
||||||
abstract class SimpleUpstreamUpdateTask : Task() {
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val repo: Property<String>
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val ref: Property<String>
|
|
||||||
|
|
||||||
@get:InputDirectory
|
|
||||||
abstract val workDir: DirectoryProperty
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val regex: Property<String>
|
|
||||||
|
|
||||||
override fun init(): Unit = with(project) {
|
|
||||||
dependsOn<CreateCompareComment>("createCompareComment", "Create Paper Compare Comment") {
|
|
||||||
onlyIf { !this@SimpleUpstreamUpdateTask.state.upToDate }
|
|
||||||
clear.convention(false)
|
|
||||||
repo.convention(extension.paperRepo)
|
|
||||||
ref.convention(extension.paperRef)
|
|
||||||
commitPropertyName.convention(extension.paperCommitName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun update() = (Git(workDir.path)("ls-remote", repo.get()).readText()?.lines()
|
|
||||||
?.filterNot("[a-z0-9]{40}\trefs/heads/${ref.get()}".toRegex()::matches)?.first()?.split("\t")?.first()
|
|
||||||
?: throw AlwaysUpToDateException("Failed to get latest commit")).let { commit ->
|
|
||||||
workDir.file("gradle.properties").path.toFile().let {
|
|
||||||
it.writeText(it.readText().replace("${regex.get()}.*".toRegex(), "${regex.get()}$commit"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
|
|
||||||
abstract class Task : DefaultTask() {
|
|
||||||
|
|
||||||
protected open fun init() {}
|
|
||||||
|
|
||||||
init {
|
|
||||||
this.init()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.utils
|
|
||||||
|
|
||||||
import io.papermc.paperweight.util.Git
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.plazmamc.alwaysuptodate.tasks.Task
|
|
||||||
import java.nio.file.Path
|
|
||||||
import kotlin.io.path.exists
|
|
||||||
|
|
||||||
val Git.path: Path
|
|
||||||
get() = Git::class.java.getDeclaredField("repo").apply { isAccessible = true }.get(this) as Path
|
|
||||||
|
|
||||||
abstract class CheckGitTask : Task() {
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun checkGit() = Git.checkForGit()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Git.revParse(): String = this("rev-parse", "HEAD").captureOut(true).out.trim()
|
|
||||||
|
|
||||||
fun Git.addCommit(vararg args: String) {
|
|
||||||
this("add", ".").executeSilently()
|
|
||||||
this("commit", "-m", *args).executeSilently()
|
|
||||||
this.wait()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Git.wait() {
|
|
||||||
val lockFile = path.resolve(".git/gc.pid")
|
|
||||||
while (lockFile.exists()) {
|
|
||||||
println("detected lockfile, waiting for it to be removed")
|
|
||||||
Thread.sleep(1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.utils
|
|
||||||
|
|
||||||
import io.papermc.paperweight.util.Command
|
|
||||||
import io.papermc.paperweight.util.directory
|
|
||||||
import org.plazmamc.alwaysuptodate.AlwaysUpToDateException
|
|
||||||
import java.nio.file.Path
|
|
||||||
import kotlin.io.path.notExists
|
|
||||||
|
|
||||||
class Gradle(private val repo: Path) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
if (repo.resolve("gradle").notExists())
|
|
||||||
throw AlwaysUpToDateException("Git repository does not exist: $repo")
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun invoke(vararg args: String): Command {
|
|
||||||
val builder = ProcessBuilder(
|
|
||||||
"java",
|
|
||||||
"-cp",
|
|
||||||
"gradle/wrapper/gradle-wrapper.jar",
|
|
||||||
"org.gradle.wrapper.GradleWrapperMain",
|
|
||||||
*args,
|
|
||||||
"--no-daemon",
|
|
||||||
"--stacktrace"
|
|
||||||
).directory(repo)
|
|
||||||
val command = builder.command()
|
|
||||||
.joinToString(" ") { if (it.codePoints().anyMatch(Character::isWhitespace)) "\"$it\"" else it }
|
|
||||||
|
|
||||||
return try {
|
|
||||||
Command(builder, command)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
throw AlwaysUpToDateException("Failed to execute command: $command", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.utils
|
|
||||||
|
|
||||||
import io.papermc.paperweight.util.Git
|
|
||||||
import io.papermc.paperweight.util.configureTask
|
|
||||||
import io.papermc.paperweight.util.path
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.Task
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.TaskProvider
|
|
||||||
import org.gradle.kotlin.dsl.get
|
|
||||||
import org.plazmamc.alwaysuptodate.AlwaysUpToDateExtension
|
|
||||||
|
|
||||||
private var extensionAccessor: AlwaysUpToDateExtension? = null
|
|
||||||
set(value) {
|
|
||||||
if (field != null) throw IllegalAccessException("ExtensionAccessor already initialized")
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
val Project.extension: AlwaysUpToDateExtension
|
|
||||||
get() {
|
|
||||||
if (extensionAccessor == null) extensionAccessor =
|
|
||||||
project.extensions["alwaysUpToDate"] as AlwaysUpToDateExtension
|
|
||||||
return extensionAccessor!!
|
|
||||||
}
|
|
||||||
|
|
||||||
val Project.git: Git get() = Git(layout.projectDirectory.path)
|
|
||||||
|
|
||||||
fun <T> Project.extension(block: AlwaysUpToDateExtension.() -> Property<T>): T =
|
|
||||||
extension.block().get()
|
|
||||||
|
|
||||||
fun Project.property(block: AlwaysUpToDateExtension.() -> Property<String>) =
|
|
||||||
this.property(extension(block)) as String
|
|
||||||
|
|
||||||
inline fun <reified T : Task> Task.dependsOn(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
noinline block: T.() -> Unit = {}
|
|
||||||
): TaskProvider<T> =
|
|
||||||
project.configureTask<T>(name, description, block).also { this.dependsOn(it) }
|
|
||||||
|
|
||||||
@JvmName("dependsOnDefaultTask")
|
|
||||||
fun Task.dependsOn(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
block: DefaultTask.() -> Unit = {}
|
|
||||||
): TaskProvider<DefaultTask> =
|
|
||||||
this.dependsOn<DefaultTask>(name, description, block)
|
|
||||||
|
|
||||||
inline fun <reified T : Task> Task.finalizedBy(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
noinline block: T.() -> Unit = {}
|
|
||||||
): TaskProvider<T> =
|
|
||||||
project.configureTask<T>(name, description, block).also { this.finalizedBy(it) }
|
|
||||||
|
|
||||||
@JvmName("finalizedByDefaultTask")
|
|
||||||
fun Task.finalizedBy(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
block: DefaultTask.() -> Unit = {}
|
|
||||||
): TaskProvider<DefaultTask> =
|
|
||||||
this.finalizedBy<DefaultTask>(name, description, block)
|
|
||||||
|
|
||||||
inline fun <reified T : Task> Task.mustRunAfter(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
noinline block: T.() -> Unit = {}
|
|
||||||
): TaskProvider<T> =
|
|
||||||
project.configureTask<T>(name, description, block).also { this.mustRunAfter(it) }
|
|
||||||
|
|
||||||
@JvmName("mustRunAfterDefaultTask")
|
|
||||||
fun Task.mustRunAfter(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
block: DefaultTask.() -> Unit = {}
|
|
||||||
): TaskProvider<DefaultTask> =
|
|
||||||
this.mustRunAfter<DefaultTask>(name, description, block)
|
|
||||||
|
|
||||||
inline fun <reified T : Task> Project.configureTask(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
noinline block: T.() -> Unit = {}
|
|
||||||
): TaskProvider<T> =
|
|
||||||
tasks.configureTask<T>(name) {
|
|
||||||
this.group = "always up to date"
|
|
||||||
this.description = description
|
|
||||||
this.block()
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmName("configureDefaultTask")
|
|
||||||
fun Project.configureTask(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
block: DefaultTask.() -> Unit = {}
|
|
||||||
): TaskProvider<DefaultTask> =
|
|
||||||
this.configureTask<DefaultTask>(name, description, block)
|
|
||||||
|
|
||||||
inline fun <reified T : Task> Project.registerTask(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
crossinline block: T.() -> Unit = {}
|
|
||||||
): TaskProvider<T> =
|
|
||||||
tasks.register(name, T::class.java) {
|
|
||||||
this.group = "always up to date"
|
|
||||||
this.description = description
|
|
||||||
this.block()
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmName("registerDefaultTask")
|
|
||||||
fun Project.registerTask(
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
block: DefaultTask.() -> Unit = {}
|
|
||||||
): TaskProvider<DefaultTask> =
|
|
||||||
this.registerTask<DefaultTask>(name, description, block)
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
package org.plazmamc.alwaysuptodate.utils
|
|
||||||
|
|
||||||
fun <A, B, C> Pair<Pair<A, B>, C>.flatten() = Triple(first.first, first.second, second)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
implementation-class=org.plazmamc.alwaysuptodate.AlwaysUpToDate
|
|
||||||
@@ -1,29 +1,10 @@
|
|||||||
org.gradle.daemon = true
|
group=org.plazmamc.plazma
|
||||||
org.gradle.caching = true
|
version=1.21.4-R0.1-SNAPSHOT
|
||||||
org.gradle.parallel = true
|
mcVersion=1.21.4
|
||||||
org.gradle.vfs.watch = false
|
|
||||||
org.gradle.jvmargs = -Xmx4G -Dfile.encoding=UTF-8 -Dgraal.CompilerConfiguration=community -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true -Dgraal.SpeculativeGuardMovement=true -Dgraal.WriteableCodeCache=true
|
|
||||||
|
|
||||||
paper.runMemoryGb = 8
|
purpurRef=a9862d7ec77a2b7690e73e635a5829f1596be84e
|
||||||
paper.runDisableWatchdog = true
|
|
||||||
|
|
||||||
group = org.plazmamc.plazma
|
org.gradle.configuration-cache=true
|
||||||
brandKey = plazmamc:plazma
|
org.gradle.caching=true
|
||||||
brandName = Plazma
|
org.gradle.parallel=true
|
||||||
providerName = PlazmaMC
|
org.gradle.vfs.watch=false
|
||||||
providerRepo = PlazmaMC/PlazmaBukkit
|
|
||||||
|
|
||||||
version = 1.21.1-R0.1-SNAPSHOT
|
|
||||||
mcVersion = 1.21.1
|
|
||||||
jdkVersion = 21
|
|
||||||
|
|
||||||
paperRepo = https://github.com/PaperMC/Paper
|
|
||||||
paperBranch = master
|
|
||||||
purpurRepo = https://github.com/PurpurMC/Purpur
|
|
||||||
purpurBranch = ver/1.21.1
|
|
||||||
pufferfishRepo = https://github.com/pufferfish-gg/Pufferfish
|
|
||||||
pufferfishBranch = ver/1.21
|
|
||||||
usePufferfish = true
|
|
||||||
|
|
||||||
paperCommit = d348cb88a9fe8d19e46102c8b9febe18f746d46b
|
|
||||||
purpurCommit = 4b57bed513aaadb0a1ecebae3796a5e93b7561ea
|
|
||||||
|
|||||||
@@ -1,15 +1,2 @@
|
|||||||
[versions]
|
# This file was generated by the Gradle 'init' task.
|
||||||
shadow = "8.1.1"
|
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
|
||||||
paperweight = "1.7.1"
|
|
||||||
paperclip = "3.0.3"
|
|
||||||
decompiler = "1.10.1"
|
|
||||||
remapper = "0.10.1"
|
|
||||||
|
|
||||||
[libraries]
|
|
||||||
remapper = { group = "net.fabricmc", name = "tiny-remapper", version.ref="remapper" }
|
|
||||||
decompiler = { group = "org.vineflower", name = "vineflower", version.ref = "decompiler" }
|
|
||||||
paperclip = { group = "io.papermc", name = "paperclip", version.ref = "paperclip" }
|
|
||||||
|
|
||||||
[plugins]
|
|
||||||
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
|
|
||||||
paperweight = { id = "io.papermc.paperweight.patcher", version.ref = "paperweight" }
|
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
6
gradlew
vendored
6
gradlew
vendored
@@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (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.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -84,7 +86,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|||||||
2
gradlew.bat
vendored
2
gradlew.bat
vendored
@@ -13,6 +13,8 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|||||||
65
initDev
65
initDev
@@ -1,65 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# To initialize your development environment,
|
|
||||||
# run below command in your terminal:
|
|
||||||
# source ./initDev
|
|
||||||
|
|
||||||
export PROJECT_DIR=$(pwd)
|
|
||||||
|
|
||||||
alias api="cd $PROJECT_DIR/*-API"
|
|
||||||
alias srv="cd $PROJECT_DIR/*-Server"
|
|
||||||
|
|
||||||
alias c="clear;"
|
|
||||||
alias ap="./gradlew --no-rebuild applyPatches"
|
|
||||||
alias aap="./gradlew --no-rebuild applyAPIPatches"
|
|
||||||
alias agp="./gradlew --no-rebuild applyGeneratedAPIPatches"
|
|
||||||
alias asp="./gradlew --no-rebuild applyServerPatches"
|
|
||||||
|
|
||||||
alias rp="./gradlew --no-rebuild rebuildPatches"
|
|
||||||
alias rap="./gradlew --no-rebuild rebuildAPIPatches"
|
|
||||||
alias rgp="./gradlew --no-rebuild rebuildGeneratedAPIPatches"
|
|
||||||
alias rsp="./gradlew --no-rebuild rebuildServerPatches"
|
|
||||||
|
|
||||||
alias lg="git log --oneline base..HEAD"
|
|
||||||
alias rc="git rebase --autosquash -i base"
|
|
||||||
alias rcc="git rebase --continue"
|
|
||||||
|
|
||||||
# generate Fixup patches for Server
|
|
||||||
function fs() {
|
|
||||||
cd ./*-Server || exit 1
|
|
||||||
garg="."
|
|
||||||
[[ "$1" == "-x" ]] && garg="--amend"
|
|
||||||
|
|
||||||
git add .
|
|
||||||
git commit "$garg" -m "fixup"
|
|
||||||
git format-patch -1
|
|
||||||
mv 0001-fixup.patch ../
|
|
||||||
|
|
||||||
cd ../
|
|
||||||
}
|
|
||||||
|
|
||||||
# generate Fixup patches for API
|
|
||||||
function fa() {
|
|
||||||
cd ./*-API || exit 1
|
|
||||||
garg="."
|
|
||||||
[[ "$1" == "-x" ]] && garg="--amend"
|
|
||||||
|
|
||||||
git add .
|
|
||||||
git commit "$garg" -m "fixup"
|
|
||||||
git format-patch -1
|
|
||||||
mv 0001-fixup.patch ../
|
|
||||||
|
|
||||||
cd ../
|
|
||||||
}
|
|
||||||
|
|
||||||
# ReApply Server Patches
|
|
||||||
function rasp() {
|
|
||||||
rm -rf ./*-Server
|
|
||||||
./gradlew applyServerPatches
|
|
||||||
}
|
|
||||||
|
|
||||||
# Commit Updated Upstream
|
|
||||||
function cuu() {
|
|
||||||
# shellcheck disable=SC2059
|
|
||||||
printf "Updated Upstream ($1)$(/bin/cat compare.txt)" | git commit -F -
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
[versions]
|
|
||||||
gson = "2.10.1"
|
|
||||||
joml = "1.10.5"
|
|
||||||
guava = "32.1.2-jre"
|
|
||||||
sentry = "5.4.0"
|
|
||||||
jspecify = "1.0.0"
|
|
||||||
fastutil = "8.5.6"
|
|
||||||
findbugs = "1.3.9"
|
|
||||||
slf4j-api = "2.0.9"
|
|
||||||
brigadier = "1.2.9"
|
|
||||||
bungeechat = "1.20-R0.2"
|
|
||||||
json-simple = "1.1.1"
|
|
||||||
annotations = "24.0.1"
|
|
||||||
checkerqual = "3.21.0"
|
|
||||||
|
|
||||||
[libraries]
|
|
||||||
joml = { group = "org.joml", name = "joml", version.ref = "joml" }
|
|
||||||
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
|
|
||||||
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
|
|
||||||
sentry = { group = "io.sentry", name = "sentry", version.ref = "sentry" }
|
|
||||||
jspecify = { group = "org.jspecify", name = "jspecify", version.ref = "jspecify" }
|
|
||||||
fastutil = { group = "it.unimi.dsi", name = "fastutil", version.ref = "fastutil" }
|
|
||||||
findbugs = { group = "com.google.code.findbugs", name = "jsr305", version.ref = "findbugs" }
|
|
||||||
brigadier = { group = "com.mojang", name = "brigadier", version.ref = "brigadier" }
|
|
||||||
slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j-api" }
|
|
||||||
bungeechat = { group = "net.md-5", name = "bungeecord-chat", version.ref = "bungeechat" }
|
|
||||||
jsonsimple = { group = "com.googlecode.json-simple", name = "json-simple", version.ref = "json-simple" }
|
|
||||||
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
|
|
||||||
checkerqual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerqual" }
|
|
||||||
|
|
||||||
[bundles]
|
|
||||||
api = [ "jspecify", "guava", "gson", "joml", "fastutil", "slf4j-api", "sentry", "brigadier" ]
|
|
||||||
annotations = [ "annotations", "checkerqual" ]
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
[versions]
|
|
||||||
asm = "9.7.1"
|
|
||||||
log4j = "2.19.0"
|
|
||||||
junit = "1.10.0"
|
|
||||||
mockito = "5.14.1"
|
|
||||||
jupiter = "5.10.0"
|
|
||||||
hamcrest = "2.2"
|
|
||||||
snakeyaml = "2.2"
|
|
||||||
adventure = "4.17.0"
|
|
||||||
commons-lang2 = "2.6"
|
|
||||||
commons-lang3 = "3.12.0"
|
|
||||||
maven-provider = "3.9.6"
|
|
||||||
maven-resolver = "1.9.18"
|
|
||||||
|
|
||||||
[libraries]
|
|
||||||
junit = { group = "org.junit.platform", name = "junit-platform-suite-engine", version.ref = "junit" }
|
|
||||||
mockito = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
|
|
||||||
jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "jupiter" }
|
|
||||||
hamcrest = { group = "org.hamcrest", name = "hamcrest", version.ref = "hamcrest" }
|
|
||||||
snakeyaml = { group = "org.yaml", name = "snakeyaml", version.ref = "snakeyaml" }
|
|
||||||
|
|
||||||
asm-head = { group = "org.ow2.asm", name = "asm", version.ref = "asm" }
|
|
||||||
asm-tree = { group = "org.ow2.asm", name = "asm-tree", version.ref = "asm" }
|
|
||||||
asm-commons = { group = "org.ow2.asm", name = "asm-commons", version.ref = "asm" }
|
|
||||||
log4j-api = { group = "org.apache.logging.log4j", name = "log4j-api", version.ref = "log4j" }
|
|
||||||
log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.ref = "log4j" }
|
|
||||||
log4j-iostreams = { group = "org.apache.logging.log4j", name = "log4j-iostreams", version.ref = "log4j" }
|
|
||||||
maven-provider = { group = "org.apache.maven", name = "maven-resolver-provider", version.ref = "maven-provider" }
|
|
||||||
maven-connector = { group = "org.apache.maven.resolver", name = "maven-resolver-connector-basic", version.ref = "maven-resolver" }
|
|
||||||
maven-transport = { group = "org.apache.maven.resolver", name = "maven-resolver-transport-http", version.ref = "maven-resolver" }
|
|
||||||
commons-lang2 = { group = "commons-lang", name = "commons-lang", version.ref = "commons-lang2" }
|
|
||||||
commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version.ref = "commons-lang3" }
|
|
||||||
|
|
||||||
adventure-bom = { group = "net.kyori", name = "adventure-bom", version.ref = "adventure" }
|
|
||||||
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
|
|
||||||
adventure-slf4j = { group = "net.kyori", name = "adventure-text-logger-slf4j", version.ref = "adventure" }
|
|
||||||
adventure-minimessage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }
|
|
||||||
adventure-serializer-gson = { group = "net.kyori", name = "adventure-text-serializer-gson", version.ref = "adventure" }
|
|
||||||
adventure-serializer-ansi = { group = "net.kyori", name = "adventure-text-serializer-ansi", version.ref = "adventure" }
|
|
||||||
adventure-serializer-plain = { group = "net.kyori", name = "adventure-text-serializer-plain", version.ref = "adventure" }
|
|
||||||
adventure-serializer-legacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" }
|
|
||||||
|
|
||||||
[bundles]
|
|
||||||
asm = [ "asm-head", "asm-commons" ]
|
|
||||||
test = [ "jupiter", "hamcrest", "mockito", "asm-tree" ]
|
|
||||||
maven = [ "maven-connector", "maven-transport" ]
|
|
||||||
adventure = [ "adventure-api", "adventure-slf4j", "adventure-minimessage", "adventure-serializer-gson", "adventure-serializer-plain", "adventure-serializer-legacy" ]
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
[versions]
|
|
||||||
art = "2.0.3"
|
|
||||||
tca = "1.3.0"
|
|
||||||
upnp = "1.0"
|
|
||||||
ansi = "1.0.3"
|
|
||||||
jansi = "3.21.0"
|
|
||||||
rhino = "1.7.14"
|
|
||||||
mysql = "8.4.0"
|
|
||||||
flare = "34637f3f87"
|
|
||||||
sqlite = "3.46.0.0"
|
|
||||||
pioneer = "2.2.0"
|
|
||||||
haproxy = "4.1.97.Final"
|
|
||||||
rewriter = "0.0.3"
|
|
||||||
srgutils = "1.0.9"
|
|
||||||
sparkapi = "0.1-20240720.200737-2"
|
|
||||||
sparknt = "1.10.105-SNAPSHOT"
|
|
||||||
velocity = "3.3.0-SNAPSHOT"
|
|
||||||
disruptor = "3.4.4"
|
|
||||||
simpleyaml = "1.8.4"
|
|
||||||
classgraph = "4.8.47"
|
|
||||||
mapping-io = "0.5.0"
|
|
||||||
configurate = "4.2.0-SNAPSHOT"
|
|
||||||
|
|
||||||
[libraries]
|
|
||||||
art = { group = "net.neoforged", name = "AutoRenamingTool", version.ref = "art" }
|
|
||||||
tca = { group = "net.minecrell", name = "terminalconsoleappender", version.ref="tca" }
|
|
||||||
ansi = { group = "net.kyori", name = "ansi", version.ref = "ansi" }
|
|
||||||
upnp = { group = "dev.omega24", name = "upnp4j", version.ref = "upnp" }
|
|
||||||
mysql = { group = "com.mysql", name = "mysql-connector-j", version.ref = "mysql" }
|
|
||||||
jansi = { group = "org.jline", name = "jline-terminal-jansi", version.ref = "jansi" }
|
|
||||||
flare = { group = "com.github.technove", name = "flare", version.ref = "flare" }
|
|
||||||
sqlite = { group = "org.xerial", name = "sqlite-jdbc", version.ref = "sqlite" }
|
|
||||||
pioneer = { group = "org.junit-pioneer", name = "junit-pioneer", version.ref = "pioneer" }
|
|
||||||
haproxy = { group = "io.netty", name = "netty-codec-haproxy", version.ref = "haproxy" }
|
|
||||||
srgutils = { group = "net.neoforged", name = "srgutils", version.ref = "srgutils" }
|
|
||||||
velocity = { group = "com.velocitypowered", name = "velocity-native", version.ref = "velocity" }
|
|
||||||
disruptor = { group = "com.lmax", name = "disruptor", version.ref = "disruptor" }
|
|
||||||
mappingio = { group = "net.fabricmc", name = "mapping-io", version.ref = "mapping-io" }
|
|
||||||
classgraph = { group = "io.github.classgraph", name = "classgraph", version.ref = "classgraph" }
|
|
||||||
simpleyaml = { group = "com.github.carleslc.Simple-YAML", name = "Simple-Yaml", version.ref = "simpleyaml" }
|
|
||||||
configurate = { group = "org.spongepowered", name = "configurate-yaml", version.ref = "configurate" }
|
|
||||||
|
|
||||||
spark-api = { group = "me.lucko", name = "spark-api", version.ref = "sparkapi" }
|
|
||||||
spark-paper = { group = "me.lucko", name = "spark-paper", version.ref = "sparknt" }
|
|
||||||
|
|
||||||
rhino-engine = { group = "org.mozilla", name = "rhino-engine", version.ref = "rhino" }
|
|
||||||
rhino-runtime = { group = "org.mozilla", name = "rhino-runtime", version.ref = "rhino" }
|
|
||||||
|
|
||||||
rewriter = { group = "io.papermc", name = "reflection-rewriter", version.ref = "rewriter" }
|
|
||||||
rewriter-runtime = { group = "io.papermc", name = "reflection-rewriter-runtime", version.ref = "rewriter" }
|
|
||||||
rewriter-generator = { group = "io.papermc", name = "reflection-rewriter-proxy-generator", version.ref = "rewriter" }
|
|
||||||
|
|
||||||
[bundles]
|
|
||||||
runtime = [ "sqlite", "mysql", "disruptor" ]
|
|
||||||
implementation = [ "spark-api", "spark-paper", "jansi", "tca", "ansi", "upnp", "haproxy", "configurate", "mappingio", "rhino-engine", "rhino-runtime", "srgutils", "art", "rewriter", "rewriter-runtime", "rewriter-generator", "flare" ]
|
|
||||||
test = [ "classgraph", "pioneer" ]
|
|
||||||
@@ -1,527 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kevin Raneri <kevin.raneri@gmail.com>
|
|
||||||
Date: Tue, 22 Oct 2024 07:31:43 +0900
|
|
||||||
Subject: [PATCH] Pufferfish API Changes
|
|
||||||
|
|
||||||
Pufferfish
|
|
||||||
Copyright (C) 2024 Pufferfish Studios LLC
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
||||||
index e7c96be769fde8375b9a1b128cc7ce474144d16d..f9b44a03fe8d9a2fea2d968f4e944a6663c6f9c9 100644
|
|
||||||
--- a/build.gradle.kts
|
|
||||||
+++ b/build.gradle.kts
|
|
||||||
@@ -52,6 +52,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:5.4.0") // Pufferfish
|
|
||||||
|
|
||||||
implementation("org.ow2.asm:asm:9.7.1")
|
|
||||||
implementation("org.ow2.asm:asm-commons:9.7.1")
|
|
||||||
@@ -131,6 +132,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}")
|
|
||||||
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..10310fdd53de28efb8a8250f6d3b0c8eb08fb68a
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java
|
|
||||||
@@ -0,0 +1,161 @@
|
|
||||||
+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.getDescription().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 e) {} // 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 e) {} // 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/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..3441cdad70da1bd523c5933b1a914688718c2657
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
|
||||||
@@ -0,0 +1,40 @@
|
|
||||||
+package gg.pufferfish.pufferfish.simd;
|
|
||||||
+
|
|
||||||
+import java.util.logging.Level;
|
|
||||||
+import java.util.logging.Logger;
|
|
||||||
+import jdk.incubator.vector.FloatVector;
|
|
||||||
+import jdk.incubator.vector.IntVector;
|
|
||||||
+import jdk.incubator.vector.VectorSpecies;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * 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.log(Level.INFO, "Max SIMD vector size on this system is " + ISPEC.vectorBitSize() + " bits (int)");
|
|
||||||
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
|
|
||||||
+
|
|
||||||
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
|
|
||||||
+ logger.log(Level.WARNING, "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..a84889d3e9cfc4d7ab5f867820a6484c6070711b
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
|
||||||
@@ -0,0 +1,35 @@
|
|
||||||
+package gg.pufferfish.pufferfish.simd;
|
|
||||||
+
|
|
||||||
+import java.util.logging.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);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..ae2464920c9412ac90b819a540ee58be0741465f
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
|
|
||||||
@@ -0,0 +1,83 @@
|
|
||||||
+package gg.pufferfish.pufferfish.simd;
|
|
||||||
+
|
|
||||||
+import java.awt.Color;
|
|
||||||
+import jdk.incubator.vector.FloatVector;
|
|
||||||
+import jdk.incubator.vector.IntVector;
|
|
||||||
+import jdk.incubator.vector.VectorMask;
|
|
||||||
+import jdk.incubator.vector.VectorSpecies;
|
|
||||||
+import org.bukkit.map.MapPalette;
|
|
||||||
+
|
|
||||||
+@Deprecated
|
|
||||||
+public class VectorMapPalette {
|
|
||||||
+
|
|
||||||
+ private static final VectorSpecies<Integer> I_SPEC = IntVector.SPECIES_PREFERRED;
|
|
||||||
+ private static final VectorSpecies<Float> F_SPEC = FloatVector.SPECIES_PREFERRED;
|
|
||||||
+
|
|
||||||
+ @Deprecated
|
|
||||||
+ public static void matchColorVectorized(int[] in, byte[] out) {
|
|
||||||
+ int speciesLength = I_SPEC.length();
|
|
||||||
+ int i;
|
|
||||||
+ for (i = 0; i < in.length - speciesLength; i += speciesLength) {
|
|
||||||
+ float[] redsArr = new float[speciesLength];
|
|
||||||
+ float[] bluesArr = new float[speciesLength];
|
|
||||||
+ float[] greensArr = new float[speciesLength];
|
|
||||||
+ int[] alphasArr = new int[speciesLength];
|
|
||||||
+
|
|
||||||
+ for (int j = 0; j < speciesLength; j++) {
|
|
||||||
+ alphasArr[j] = (in[i + j] >> 24) & 0xFF;
|
|
||||||
+ redsArr[j] = (in[i + j] >> 16) & 0xFF;
|
|
||||||
+ greensArr[j] = (in[i + j] >> 8) & 0xFF;
|
|
||||||
+ bluesArr[j] = (in[i + j] >> 0) & 0xFF;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ IntVector alphas = IntVector.fromArray(I_SPEC, alphasArr, 0);
|
|
||||||
+ FloatVector reds = FloatVector.fromArray(F_SPEC, redsArr, 0);
|
|
||||||
+ FloatVector greens = FloatVector.fromArray(F_SPEC, greensArr, 0);
|
|
||||||
+ FloatVector blues = FloatVector.fromArray(F_SPEC, bluesArr, 0);
|
|
||||||
+ IntVector resultIndex = IntVector.zero(I_SPEC);
|
|
||||||
+ VectorMask<Integer> modificationMask = VectorMask.fromLong(I_SPEC, 0xffffffff);
|
|
||||||
+
|
|
||||||
+ modificationMask = modificationMask.and(alphas.lt(128).not());
|
|
||||||
+ FloatVector bestDistances = FloatVector.broadcast(F_SPEC, Float.MAX_VALUE);
|
|
||||||
+
|
|
||||||
+ for (int c = 4; c < MapPalette.colors.length; c++) {
|
|
||||||
+ // We're using 32-bit floats here because it's 2x faster and nobody will know the difference.
|
|
||||||
+ // For correctness, the original algorithm uses 64-bit floats instead. Completely unnecessary.
|
|
||||||
+ FloatVector compReds = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getRed());
|
|
||||||
+ FloatVector compGreens = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getGreen());
|
|
||||||
+ FloatVector compBlues = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getBlue());
|
|
||||||
+
|
|
||||||
+ FloatVector rMean = reds.add(compReds).div(2.0f);
|
|
||||||
+ FloatVector rDiff = reds.sub(compReds);
|
|
||||||
+ FloatVector gDiff = greens.sub(compGreens);
|
|
||||||
+ FloatVector bDiff = blues.sub(compBlues);
|
|
||||||
+
|
|
||||||
+ FloatVector weightR = rMean.div(256.0f).add(2);
|
|
||||||
+ FloatVector weightG = FloatVector.broadcast(F_SPEC, 4.0f);
|
|
||||||
+ FloatVector weightB = FloatVector.broadcast(F_SPEC, 255.0f).sub(rMean).div(256.0f).add(2.0f);
|
|
||||||
+
|
|
||||||
+ FloatVector distance = weightR.mul(rDiff).mul(rDiff).add(weightG.mul(gDiff).mul(gDiff)).add(weightB.mul(bDiff).mul(bDiff));
|
|
||||||
+
|
|
||||||
+ // Now we compare to the best distance we've found.
|
|
||||||
+ // This mask contains a "1" if better, and a "0" otherwise.
|
|
||||||
+ VectorMask<Float> bestDistanceMask = distance.lt(bestDistances);
|
|
||||||
+ bestDistances = bestDistances.blend(distance, bestDistanceMask); // Update the best distances
|
|
||||||
+
|
|
||||||
+ // Update the result array
|
|
||||||
+ // We also AND with the modification mask because we don't want to interfere if the alpha value isn't large enough.
|
|
||||||
+ resultIndex = resultIndex.blend(c, bestDistanceMask.cast(I_SPEC).and(modificationMask)); // Update the results
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ for (int j = 0; j < speciesLength; j++) {
|
|
||||||
+ int index = resultIndex.lane(j);
|
|
||||||
+ out[i + j] = (byte) (index < 128 ? index : -129 + (index - 127));
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // For the final ones, fall back to the regular method
|
|
||||||
+ for (; i < in.length; i++) {
|
|
||||||
+ out[i] = MapPalette.matchColor(new Color(in[i], true));
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/bukkit/map/MapPalette.java b/src/main/java/org/bukkit/map/MapPalette.java
|
|
||||||
index c80faa079eca1564847070f0338fc98024639829..e632d51d3487eb4807243b6705999ad124466bf5 100644
|
|
||||||
--- a/src/main/java/org/bukkit/map/MapPalette.java
|
|
||||||
+++ b/src/main/java/org/bukkit/map/MapPalette.java
|
|
||||||
@@ -1,6 +1,7 @@
|
|
||||||
package org.bukkit.map;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
+import gg.pufferfish.pufferfish.simd.SIMDDetection; // Pufferfish
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Image;
|
|
||||||
@@ -40,7 +41,7 @@ public final class MapPalette {
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
- static final Color[] colors = {
|
|
||||||
+ public static final Color[] colors = { // Pufferfish - public access
|
|
||||||
c(0, 0, 0, 0), c(0, 0, 0, 0), c(0, 0, 0, 0), c(0, 0, 0, 0),
|
|
||||||
c(89, 125, 39), c(109, 153, 48), c(127, 178, 56), c(67, 94, 29),
|
|
||||||
c(174, 164, 115), c(213, 201, 140), c(247, 233, 163), c(130, 123, 86),
|
|
||||||
@@ -211,9 +212,15 @@ public final class MapPalette {
|
|
||||||
temp.getRGB(0, 0, temp.getWidth(), temp.getHeight(), pixels, 0, temp.getWidth());
|
|
||||||
|
|
||||||
byte[] result = new byte[temp.getWidth() * temp.getHeight()];
|
|
||||||
+ // Pufferfish start
|
|
||||||
+ if (!SIMDDetection.isEnabled) {
|
|
||||||
for (int i = 0; i < pixels.length; i++) {
|
|
||||||
result[i] = matchColor(new Color(pixels[i], true));
|
|
||||||
}
|
|
||||||
+ } else {
|
|
||||||
+ gg.pufferfish.pufferfish.simd.VectorMapPalette.matchColorVectorized(pixels, result);
|
|
||||||
+ }
|
|
||||||
+ // Pufferfish end
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
||||||
index 003bece642b682985625db93cad93026352bfc66..e8ba4f1108f2548a487877027e37d81fc150e042 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 eaefbb00e9993d54906cc8cf35cf753c0d6c7707..301e82369603f3dd6e6c1bd380da4bacacd7ef6c 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) {
|
|
||||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
||||||
index 7e4f7cb2afbc145e532285c793573ad107bc3033..12449e18180d604e9cbbc744da74a8b222a18e1f 100644
|
|
||||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
||||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
||||||
@@ -50,6 +50,8 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
|
||||||
private io.papermc.paper.plugin.provider.classloader.PluginClassLoaderGroup classLoaderGroup; // Paper
|
|
||||||
public io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext; // Paper
|
|
||||||
|
|
||||||
+ private boolean closed = false; // Pufferfish
|
|
||||||
+
|
|
||||||
static {
|
|
||||||
ClassLoader.registerAsParallelCapable();
|
|
||||||
}
|
|
||||||
@@ -197,6 +199,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
|
||||||
throw new ClassNotFoundException(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ public boolean _airplane_hasClass(@NotNull String name) { return this.classes.containsKey(name); } // Pufferfish
|
|
||||||
@Override
|
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
|
||||||
if (name.startsWith("org.bukkit.") || name.startsWith("net.minecraft.")) {
|
|
||||||
@@ -204,7 +207,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
|
||||||
}
|
|
||||||
Class<?> result = classes.get(name);
|
|
||||||
|
|
||||||
- if (result == null) {
|
|
||||||
+ if (result == null && !this.closed) { // Pufferfish
|
|
||||||
String path = name.replace('.', '/').concat(".class");
|
|
||||||
JarEntry entry = jar.getJarEntry(path);
|
|
||||||
|
|
||||||
@@ -251,6 +254,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
|
||||||
this.setClass(name, result); // Paper
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (result == null) throw new ClassNotFoundException(name); // Pufferfish
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -265,6 +269,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
|
||||||
// Paper end
|
|
||||||
super.close();
|
|
||||||
} finally {
|
|
||||||
+ this.closed = true; // Pufferfish
|
|
||||||
jar.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,150 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 14 Jan 2024 19:50:29 +0900
|
|
||||||
Subject: [PATCH] Use Gradle Version Catalogs
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
||||||
index f536f8f42b99e4b7dc2e25785617837fbc405b5b..51ef37146672e17ac140d260fbc229bcbd4ad049 100644
|
|
||||||
--- a/build.gradle.kts
|
|
||||||
+++ b/build.gradle.kts
|
|
||||||
@@ -9,11 +9,13 @@ java {
|
|
||||||
withJavadocJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
+/* // Plazma - Use Gradle Versuib Catalogs
|
|
||||||
val annotationsVersion = "24.1.0"
|
|
||||||
val bungeeCordChatVersion = "1.20-R0.2"
|
|
||||||
val adventureVersion = "4.17.0"
|
|
||||||
val slf4jVersion = "2.0.9"
|
|
||||||
val log4jVersion = "2.17.1"
|
|
||||||
+ */
|
|
||||||
val apiAndDocs: Configuration by configurations.creating {
|
|
||||||
attributes {
|
|
||||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
|
|
||||||
@@ -27,57 +29,29 @@ configurations.api {
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
- api("com.mojang:brigadier:1.2.9") // Paper - Brigadier command api
|
|
||||||
- // api dependencies are listed transitively to API consumers
|
|
||||||
- api("com.google.guava:guava:32.1.2-jre")
|
|
||||||
- api("com.google.code.gson:gson:2.10.1")
|
|
||||||
- // Paper start - adventure
|
|
||||||
- api("net.md-5:bungeecord-chat:$bungeeCordChatVersion-deprecated+build.18") {
|
|
||||||
- exclude("com.google.guava", "guava")
|
|
||||||
- }
|
|
||||||
- // Paper - adventure
|
|
||||||
- api("org.yaml:snakeyaml:2.2")
|
|
||||||
- api("org.joml:joml:1.10.5")
|
|
||||||
- // Paper start
|
|
||||||
- api("com.googlecode.json-simple:json-simple:1.1.1") {
|
|
||||||
- isTransitive = false // includes junit
|
|
||||||
- }
|
|
||||||
- api("it.unimi.dsi:fastutil:8.5.6")
|
|
||||||
- apiAndDocs(platform("net.kyori:adventure-bom:$adventureVersion"))
|
|
||||||
- apiAndDocs("net.kyori:adventure-api")
|
|
||||||
- apiAndDocs("net.kyori:adventure-text-minimessage")
|
|
||||||
- apiAndDocs("net.kyori:adventure-text-serializer-gson")
|
|
||||||
- apiAndDocs("net.kyori:adventure-text-serializer-legacy")
|
|
||||||
- apiAndDocs("net.kyori:adventure-text-serializer-plain")
|
|
||||||
- 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:5.4.0") // Pufferfish
|
|
||||||
-
|
|
||||||
- implementation("org.ow2.asm:asm:9.7.1")
|
|
||||||
- implementation("org.ow2.asm:asm-commons:9.7.1")
|
|
||||||
- // Paper end
|
|
||||||
-
|
|
||||||
- api("org.apache.maven:maven-resolver-provider:3.9.6") // Paper - make API dependency for Paper Plugins
|
|
||||||
- compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
|
|
||||||
- compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
|
||||||
-
|
|
||||||
- val annotations = "org.jetbrains:annotations:$annotationsVersion" // Paper - we don't want Java 5 annotations...
|
|
||||||
- compileOnly(annotations)
|
|
||||||
- testCompileOnly(annotations)
|
|
||||||
-
|
|
||||||
- // Paper start - add checker
|
|
||||||
- val checkerQual = "org.checkerframework:checker-qual:3.33.0"
|
|
||||||
- compileOnlyApi(checkerQual)
|
|
||||||
- testCompileOnly(checkerQual)
|
|
||||||
- // Paper end
|
|
||||||
- api("org.jspecify:jspecify:1.0.0") // Paper - add jspecify
|
|
||||||
-
|
|
||||||
- testImplementation("org.apache.commons:commons-lang3:3.12.0")
|
|
||||||
- testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
|
||||||
- testImplementation("org.hamcrest:hamcrest:2.2")
|
|
||||||
- testImplementation("org.mockito:mockito-core:5.14.1")
|
|
||||||
- testImplementation("org.ow2.asm:asm-tree:9.7.1")
|
|
||||||
+ // Plazma start - Use Gradle Version Catalogs
|
|
||||||
+ implementation(common.bundles.asm)
|
|
||||||
+
|
|
||||||
+ api(api.bundles.api)
|
|
||||||
+ api(common.snakeyaml)
|
|
||||||
+ api(common.log4j.api)
|
|
||||||
+ api(common.maven.provider)
|
|
||||||
+ api(api.jsonsimple) { isTransitive = false }
|
|
||||||
+ api(api.bungeechat) { exclude("com.google.guava", "guava") }
|
|
||||||
+ apiAndDocs(platform(common.adventure.bom))
|
|
||||||
+ apiAndDocs(common.bundles.adventure)
|
|
||||||
+
|
|
||||||
+ compileOnly(common.bundles.maven)
|
|
||||||
+ compileOnly(api.annotations)
|
|
||||||
+ compileOnlyApi(api.checkerqual)
|
|
||||||
+
|
|
||||||
+ testImplementation(common.asm.tree)
|
|
||||||
+ testImplementation(common.commons.lang3)
|
|
||||||
+ testImplementation(common.bundles.test)
|
|
||||||
+
|
|
||||||
+ testCompileOnly(api.annotations)
|
|
||||||
+ testCompileOnly(api.checkerqual)
|
|
||||||
+ // Plazma end
|
|
||||||
}
|
|
||||||
|
|
||||||
// Paper start
|
|
||||||
@@ -158,27 +132,24 @@ tasks.withType<Javadoc> {
|
|
||||||
options.use()
|
|
||||||
options.isDocFilesSubDirs = true
|
|
||||||
options.links(
|
|
||||||
- "https://guava.dev/releases/32.1.2-jre/api/docs/",
|
|
||||||
- "https://javadoc.io/doc/org.yaml/snakeyaml/2.2/",
|
|
||||||
- "https://javadoc.io/doc/org.jetbrains/annotations/$annotationsVersion/", // Paper - we don't want Java 5 annotations
|
|
||||||
- // "https://javadoc.io/doc/net.md-5/bungeecord-chat/$bungeeCordChatVersion/", // Paper - don't link to bungee chat
|
|
||||||
- // Paper start - add missing javadoc links
|
|
||||||
- "https://javadoc.io/doc/org.joml/joml/1.10.5/index.html",
|
|
||||||
- "https://www.javadoc.io/doc/com.google.code.gson/gson/2.10.1",
|
|
||||||
"https://jspecify.dev/docs/api/",
|
|
||||||
- // Paper end
|
|
||||||
- // Paper start
|
|
||||||
- "https://jd.advntr.dev/api/$adventureVersion/",
|
|
||||||
- "https://jd.advntr.dev/key/$adventureVersion/",
|
|
||||||
- "https://jd.advntr.dev/text-minimessage/$adventureVersion/",
|
|
||||||
- "https://jd.advntr.dev/text-serializer-gson/$adventureVersion/",
|
|
||||||
- "https://jd.advntr.dev/text-serializer-legacy/$adventureVersion/",
|
|
||||||
- "https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
|
|
||||||
- "https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/",
|
|
||||||
- "https://javadoc.io/doc/org.slf4j/slf4j-api/$slf4jVersion/",
|
|
||||||
- "https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/$log4jVersion/",
|
|
||||||
- // Paper end
|
|
||||||
- "https://javadoc.io/doc/org.apache.maven.resolver/maven-resolver-api/1.7.3", // Paper
|
|
||||||
+ // Plazma start - Use Gradle Version Catalogs
|
|
||||||
+ "https://jd.advntr.dev/api/${common.adventure.api.orNull?.version}/",
|
|
||||||
+ "https://jd.advntr.dev/key/${common.adventure.api.orNull?.version}/",
|
|
||||||
+ "https://jd.advntr.dev/text-minimessage/${common.adventure.api.orNull?.version}/",
|
|
||||||
+ "https://jd.advntr.dev/text-serializer-gson/${common.adventure.api.orNull?.version}/",
|
|
||||||
+ "https://jd.advntr.dev/text-serializer-legacy/${common.adventure.api.orNull?.version}/",
|
|
||||||
+ "https://jd.advntr.dev/text-serializer-plain/${common.adventure.api.orNull?.version}/",
|
|
||||||
+ "https://jd.advntr.dev/text-logger-slf4j/${common.adventure.api.orNull?.version}/",
|
|
||||||
+ "https://guava.dev/releases/${api.guava.orNull?.version}/api/docs/",
|
|
||||||
+ "https://javadoc.io/doc/org.yaml/snakeyaml/${common.snakeyaml.orNull?.version}/",
|
|
||||||
+ "https://javadoc.io/doc/org.jetbrains/annotations/${api.annotations.orNull?.version}/",
|
|
||||||
+ "https://javadoc.io/doc/org.joml/joml/${api.joml.orNull?.version}/index.html",
|
|
||||||
+ "https://www.javadoc.io/doc/com.google.code.gson/gson/${api.gson.orNull?.version}",
|
|
||||||
+ "https://javadoc.io/doc/org.slf4j/slf4j-api/${api.slf4j.api.orNull?.version}/",
|
|
||||||
+ "https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/${common.log4j.api.orNull?.version}/",
|
|
||||||
+ "https://javadoc.io/doc/org.apache.maven.resolver/maven-resolver-api/${common.maven.connector.orNull?.version}",
|
|
||||||
+ // Plazma end
|
|
||||||
)
|
|
||||||
options.tags("apiNote:a:API Note:")
|
|
||||||
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Tue, 14 May 2024 18:36:30 +0900
|
|
||||||
Subject: [PATCH] Rebrand
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/MIT.txt b/MIT.txt
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..67d405764ed68083d0164b1af0eabc0af7f6efea
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/MIT.txt
|
|
||||||
@@ -0,0 +1,21 @@
|
|
||||||
+The MIT License (MIT)
|
|
||||||
+
|
|
||||||
+Copyright (c) 2024 Paper Contributors
|
|
||||||
+
|
|
||||||
+Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
+a copy of this software and associated documentation files (the "Software"),
|
|
||||||
+to deal in the Software without restriction, including without limitation
|
|
||||||
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
+and/or sell copies of the Software, and to permit persons to whom
|
|
||||||
+the Software is furnished to do so, subject to the following conditions:
|
|
||||||
+
|
|
||||||
+The above copyright notice and this permission notice shall be included
|
|
||||||
+in all copies or substantial portions of the Software.
|
|
||||||
+
|
|
||||||
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
||||||
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
+AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
||||||
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
||||||
+OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
diff --git a/src/main/java/co/aikar/timings/TimingHandler.java b/src/main/java/co/aikar/timings/TimingHandler.java
|
|
||||||
index 199789d56d22fcb1b77ebd56805cc28aa5a5ab0a..3b3bcfa6fa2dbcc7fef899cc7570da097437ab3a 100644
|
|
||||||
--- a/src/main/java/co/aikar/timings/TimingHandler.java
|
|
||||||
+++ b/src/main/java/co/aikar/timings/TimingHandler.java
|
|
||||||
@@ -127,7 +127,7 @@ class TimingHandler implements Timing {
|
|
||||||
while ((last = TIMING_STACK.removeLast()) != this) {
|
|
||||||
last.timingDepth = 0;
|
|
||||||
if ("Minecraft".equalsIgnoreCase(last.identifier.group)) {
|
|
||||||
- Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Look above this for any errors and report this to Paper unless it has a plugin in the stack trace (" + last.identifier + " did not stopTiming)");
|
|
||||||
+ Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Look above this for any errors and report this to " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " unless it has a plugin in the stack trace (" + last.identifier + " did not stopTiming)");
|
|
||||||
} else {
|
|
||||||
Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Report this to the plugin " + last.identifier.group + " (Look for errors above this in the logs) (" + last.identifier + " did not stopTiming)", new Throwable());
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
|
||||||
index 7196594e07af19a14c320d77df893978525fe386..843283cfee6e481addea1f1c18147639c70ddfe0 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
|
||||||
@@ -33,6 +33,29 @@ public interface ServerBuildInfo {
|
|
||||||
Key BRAND_PURPUR_ID = Key.key("purpurmc", "purpur");
|
|
||||||
// Purpur end
|
|
||||||
|
|
||||||
+ // Plazma start - Rebranding
|
|
||||||
+ /**
|
|
||||||
+ * The brand id for Plazma.
|
|
||||||
+ */
|
|
||||||
+ Key BRAND_PLAZMA_ID = Key.key("plazmamc", "plazma");
|
|
||||||
+
|
|
||||||
+ // For those who fork Plazma - please add the new branding key here
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * The brand id of the server.
|
|
||||||
+ */
|
|
||||||
+ Key BRAND_ID = BRAND_PLAZMA_ID;
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Supported brands of the server.
|
|
||||||
+ */
|
|
||||||
+ java.util.List<Key> SUPPORTED_BRANDS = java.util.Arrays.asList(
|
|
||||||
+ BRAND_PAPER_ID,
|
|
||||||
+ BRAND_PURPUR_ID,
|
|
||||||
+ BRAND_PLAZMA_ID
|
|
||||||
+ );
|
|
||||||
+ // Plazma end - Rebranding
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Gets the {@code ServerBuildInfo}.
|
|
||||||
*
|
|
||||||
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
||||||
index c880d0010849ab733ad13bbd18fab3c864d0cf61..e7d7bcbd3dbaf69fd7b9375d4f53ef9420c6b46a 100644
|
|
||||||
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
||||||
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
||||||
@@ -259,7 +259,7 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
// Purpur start
|
|
||||||
int distance = getVersionFetcher().distance();
|
|
||||||
final Component message = Component.join(net.kyori.adventure.text.JoinConfiguration.separator(Component.newline()),
|
|
||||||
- ChatColor.parseMM("<grey>Current Purpur Version: %s%s*", distance == 0 ? "<green>" : distance > 0 ? "<yellow>" : "<red>", Bukkit.getVersion()),
|
|
||||||
+ ChatColor.parseMM("<grey>Current " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " Version: %s%s*", distance == 0 ? "<green>" : distance > 0 ? "<yellow>" : "<red>", Bukkit.getVersion()),
|
|
||||||
// Purpur end
|
|
||||||
msg
|
|
||||||
);
|
|
||||||
@@ -282,6 +282,7 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* // Plazma - Fork-friendly Rebranding
|
|
||||||
private static int getDistance(@NotNull String repo, @NotNull String hash) {
|
|
||||||
try {
|
|
||||||
BufferedReader reader = Resources.asCharSource(
|
|
||||||
@@ -302,4 +303,5 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ */ // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/plugin/EventExecutor.java b/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
||||||
index 60e086be70529e0804280b24a2a3e7ae72d8d363..dcf1d53af919e94a6947bc3f81121bd4fad1a163 100644
|
|
||||||
--- a/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
||||||
+++ b/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
||||||
@@ -54,7 +54,7 @@ public interface EventExecutor {
|
|
||||||
if (m.getReturnType() != Void.TYPE) {
|
|
||||||
final org.bukkit.plugin.java.JavaPlugin plugin = org.bukkit.plugin.java.JavaPlugin.getProvidingPlugin(m.getDeclaringClass());
|
|
||||||
org.bukkit.Bukkit.getLogger().warning("@EventHandler method " + m.getDeclaringClass().getName() + (Modifier.isStatic(m.getModifiers()) ? '.' : '#') + m.getName()
|
|
||||||
- + " returns non-void type " + m.getReturnType().getName() + ". This is unsupported behavior and will no longer work in a future version of Paper."
|
|
||||||
+ + " returns non-void type " + m.getReturnType().getName() + ". This is unsupported behavior and will no longer work in a future version of " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + "." // Plazma - Fork-friendly Rebranding
|
|
||||||
+ " This should be reported to the developers of " + plugin.getPluginMeta().getDisplayName() + " (" + String.join(",", plugin.getPluginMeta().getAuthors()) + ')');
|
|
||||||
}
|
|
||||||
if (Modifier.isStatic(m.getModifiers())) {
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <alphakr93@outlook.com>
|
|
||||||
Date: Thu, 22 Dec 2022 20:20:03 +0900
|
|
||||||
Subject: [PATCH] Plazma Configurations
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
||||||
index eb29794f6ca2efc9cde4dd1685822f9a3a73f3b9..d84c788fe1183833c86cde0ba8e174418cede950 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
|
||||||
@@ -2277,6 +2277,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|
||||||
}
|
|
||||||
// Purpur end
|
|
||||||
|
|
||||||
+ // Plazma start - Plazma Configuration API
|
|
||||||
+ @NotNull
|
|
||||||
+ public org.bukkit.configuration.file.YamlConfiguration getPlazmaConfig() {
|
|
||||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
+ }
|
|
||||||
+ // Plazma end
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Sends the component to the player
|
|
||||||
*
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Mon, 6 May 2024 20:43:37 +0900
|
|
||||||
Subject: [PATCH] Various API Tweaks
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/MaterialTags.java b/src/main/java/com/destroystokyo/paper/MaterialTags.java
|
|
||||||
index be212b4fbeabab32a4dab6ae554768c368efaa88..2c08e2000fc1c2cfaae9b82c57c0f2a5079311f1 100644
|
|
||||||
--- a/src/main/java/com/destroystokyo/paper/MaterialTags.java
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/MaterialTags.java
|
|
||||||
@@ -584,6 +584,15 @@ public class MaterialTags {
|
|
||||||
.add(material -> material.name().startsWith("DEEPSLATE_") && material.name().endsWith("_ORE"))
|
|
||||||
.ensureSize("DEEPSLATE_ORES", 8).lock();
|
|
||||||
|
|
||||||
+ // Plazma start - Various API Tweaks
|
|
||||||
+ /**
|
|
||||||
+ * Covers the variants of stone ores.
|
|
||||||
+ */
|
|
||||||
+ public static final MaterialSetTag STONE_ORES = new MaterialSetTag(keyFor("stone_ores"))
|
|
||||||
+ .add(material -> !material.name().startsWith("DEEPSLATE_") && !material.name().startsWith("NETHER_") && material.name().endsWith("_ORE"))
|
|
||||||
+ .ensureSize("STONE_ORES", 8).lock();
|
|
||||||
+ // Plazma end - Various API Tweaks
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Covers the variants of raw ore blocks.
|
|
||||||
*/
|
|
||||||
24
patches/api/0008-Add-option-to-shoot-fireball.patch
Normal file
24
patches/api/0008-Add-option-to-shoot-fireball.patch
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Sat, 14 Dec 2024 12:25:43 +0900
|
||||||
|
Subject: [PATCH] Add option to shoot fireball
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java
|
||||||
|
index 361db256296d776c27e601c923b2cdc61967122b..8a740bdd99b683255fdd7ebf81f28ceca8b030f8 100644
|
||||||
|
--- a/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java
|
||||||
|
+++ b/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java
|
||||||
|
@@ -224,6 +224,12 @@ public class CreatureSpawnEvent extends EntitySpawnEvent {
|
||||||
|
/**
|
||||||
|
* When an entity is missing a SpawnReason
|
||||||
|
*/
|
||||||
|
- DEFAULT
|
||||||
|
+ DEFAULT,
|
||||||
|
+ // Plazma start - Option to shoot fireballs
|
||||||
|
+ /*
|
||||||
|
+ * When a player shoots a fire charge
|
||||||
|
+ */
|
||||||
|
+ FIRE_CHARGE,
|
||||||
|
+ // Plazma end - Option to shoot fireballs
|
||||||
|
}
|
||||||
|
}
|
||||||
342
patches/api/feature/0007-Reduce-allocations.patch
Normal file
342
patches/api/feature/0007-Reduce-allocations.patch
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Mon, 4 Nov 2024 16:04:55 +0900
|
||||||
|
Subject: [PATCH] Reduce allocations
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/command/brigadier/BasicCommand.java b/src/main/java/io/papermc/paper/command/brigadier/BasicCommand.java
|
||||||
|
index c89d6c4c38e2390cb11ffba182f8741d3726cfd1..2451f466ae6f953b01ad2cbaeac7d163f09f1c5c 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/command/brigadier/BasicCommand.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/command/brigadier/BasicCommand.java
|
||||||
|
@@ -16,6 +16,17 @@ import org.jspecify.annotations.Nullable;
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface BasicCommand {
|
||||||
|
|
||||||
|
+ // Plazma start - Reduce allocations
|
||||||
|
+ /**
|
||||||
|
+ * Executes the command with the given {@link CommandSourceStack} and arguments.
|
||||||
|
+ *
|
||||||
|
+ * @param commandSourceStack the commandSourceStack of the command
|
||||||
|
+ */
|
||||||
|
+ default void execute(CommandSourceStack commandSourceStack) {
|
||||||
|
+ this.execute(commandSourceStack, org.plazmamc.plazma.constants.Null.STRING);
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - Reduce allocations
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Executes the command with the given {@link CommandSourceStack} and arguments.
|
||||||
|
*
|
||||||
|
diff --git a/src/main/java/org/bukkit/Fluid.java b/src/main/java/org/bukkit/Fluid.java
|
||||||
|
index a3ff4fefaf50f3e99a69ba68cbe8e30c95dac5df..5bbecd907e222f9adcf726bccab63c9ef59f5c14 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Fluid.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Fluid.java
|
||||||
|
@@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
* Represents a fluid type.
|
||||||
|
*/
|
||||||
|
public interface Fluid extends OldEnum<Fluid>, Keyed {
|
||||||
|
+ Fluid[] EMPTY_ARRAY = new Fluid[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No fluid.
|
||||||
|
@@ -57,6 +58,6 @@ public interface Fluid extends OldEnum<Fluid>, Keyed {
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static Fluid[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.FLUID).toArray(new Fluid[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.FLUID).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/attribute/Attribute.java b/src/main/java/org/bukkit/attribute/Attribute.java
|
||||||
|
index 521f035409ee61a9ad73d39bec938f2938892570..6e53135579426cb677bf34a0813db8268d550428 100644
|
||||||
|
--- a/src/main/java/org/bukkit/attribute/Attribute.java
|
||||||
|
+++ b/src/main/java/org/bukkit/attribute/Attribute.java
|
||||||
|
@@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
* Types of attributes which may be present on an {@link Attributable}.
|
||||||
|
*/
|
||||||
|
public interface Attribute extends OldEnum<Attribute>, Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
|
||||||
|
+ Attribute[] EMPTY_ARRAY = new Attribute[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum health of an Entity.
|
||||||
|
@@ -170,6 +171,6 @@ public interface Attribute extends OldEnum<Attribute>, Keyed, Translatable, net.
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static Attribute[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.ATTRIBUTE).toArray(new Attribute[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.ATTRIBUTE).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/block/Biome.java b/src/main/java/org/bukkit/block/Biome.java
|
||||||
|
index 20fc2b30fdcdedb012dfe129e746d0b9e162fc36..ca97debfd1a204d15bf5f6c176612cccc2596537 100644
|
||||||
|
--- a/src/main/java/org/bukkit/block/Biome.java
|
||||||
|
+++ b/src/main/java/org/bukkit/block/Biome.java
|
||||||
|
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
* which can be accessed via {@link Registry#BIOME}.
|
||||||
|
*/
|
||||||
|
public interface Biome extends OldEnum<Biome>, Keyed, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
|
||||||
|
+ Biome[] EMPTY_ARRAY = new Biome[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
Biome OCEAN = getBiome("ocean");
|
||||||
|
Biome PLAINS = getBiome("plains");
|
||||||
|
@@ -125,7 +126,7 @@ public interface Biome extends OldEnum<Biome>, Keyed, net.kyori.adventure.transl
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static Biome[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.BIOME).toArray(new Biome[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.BIOME).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paper start
|
||||||
|
diff --git a/src/main/java/org/bukkit/block/banner/PatternType.java b/src/main/java/org/bukkit/block/banner/PatternType.java
|
||||||
|
index 24b58ed80f3dd7c6b35bb18071000af845d18ba4..13ad0ba6320acd054a665d1749871a14cfd1a520 100644
|
||||||
|
--- a/src/main/java/org/bukkit/block/banner/PatternType.java
|
||||||
|
+++ b/src/main/java/org/bukkit/block/banner/PatternType.java
|
||||||
|
@@ -12,6 +12,8 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public interface PatternType extends OldEnum<PatternType>, Keyed {
|
||||||
|
+ PatternType[] EMPTY_ARRAY = new PatternType[0]; // Plazma - Reduce allocations
|
||||||
|
+
|
||||||
|
PatternType BASE = getType("base");
|
||||||
|
PatternType SQUARE_BOTTOM_LEFT = getType("square_bottom_left");
|
||||||
|
PatternType SQUARE_BOTTOM_RIGHT = getType("square_bottom_right");
|
||||||
|
@@ -140,6 +142,6 @@ public interface PatternType extends OldEnum<PatternType>, Keyed {
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static PatternType[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.BANNER_PATTERN).toArray(new PatternType[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.BANNER_PATTERN).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
|
||||||
|
index 74384a56eebbce41d431db2507c55eddbcf50a41..ef3afe91312de1d0fb38d985e0421ceae59d7e57 100644
|
||||||
|
--- a/src/main/java/org/bukkit/command/Command.java
|
||||||
|
+++ b/src/main/java/org/bukkit/command/Command.java
|
||||||
|
@@ -58,6 +58,19 @@ public abstract class Command {
|
||||||
|
this.activeAliases = new ArrayList<String>(aliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Plazma start - Reduce allocations
|
||||||
|
+ /**
|
||||||
|
+ * Executes the command, returning its success
|
||||||
|
+ *
|
||||||
|
+ * @param sender Source object which is executing this command
|
||||||
|
+ * @param commandLabel The alias of the command used
|
||||||
|
+ * @return true if the command was successful, otherwise false
|
||||||
|
+ */
|
||||||
|
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel) {
|
||||||
|
+ return this.execute(sender, commandLabel, org.plazmamc.plazma.constants.Null.STRING);
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - Reduce allocations
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Executes the command, returning its success
|
||||||
|
*
|
||||||
|
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
|
||||||
|
index a824ac90e78d3d7f90b01397270e54422d88e8b9..95df10ad8a53942de435cec7db57c1bb496097dc 100644
|
||||||
|
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
|
||||||
|
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
|
||||||
|
@@ -15,6 +15,8 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
* The various type of enchantments that may be added to armour or weapons
|
||||||
|
*/
|
||||||
|
public abstract class Enchantment implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
|
||||||
|
+ private static final Enchantment[] EMPTY_ARRAY = new Enchantment[0]; // Plazma - Reduce allocations
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Provides protection against environmental damage
|
||||||
|
*/
|
||||||
|
@@ -536,6 +538,6 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.20.3")
|
||||||
|
public static Enchantment[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.ENCHANTMENT).toArray(new Enchantment[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.ENCHANTMENT).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Cat.java b/src/main/java/org/bukkit/entity/Cat.java
|
||||||
|
index fca4671c6976aee9e981ef344244f9322651d0c9..7dc1744fba576683155e7970832794c05ceff768 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Cat.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Cat.java
|
||||||
|
@@ -51,6 +51,7 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC
|
||||||
|
* Represents the various different cat types there are.
|
||||||
|
*/
|
||||||
|
interface Type extends OldEnum<Type>, Keyed {
|
||||||
|
+ Type[] EMPTY_ARRAY = new Type[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
Type TABBY = getType("tabby");
|
||||||
|
Type BLACK = getType("black");
|
||||||
|
@@ -89,7 +90,7 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static Type[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.CAT_VARIANT).toArray(new Type[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.CAT_VARIANT).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Frog.java b/src/main/java/org/bukkit/entity/Frog.java
|
||||||
|
index f661a6b4797dd814a197e9245bcb2ddf2fca773f..58bf414cd753299abc54c45b3036d3fdbf9170dc 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Frog.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Frog.java
|
||||||
|
@@ -49,6 +49,7 @@ public interface Frog extends Animals {
|
||||||
|
* Represents the variant of a frog - ie its color.
|
||||||
|
*/
|
||||||
|
interface Variant extends OldEnum<Variant>, Keyed {
|
||||||
|
+ Variant[] EMPTY_ARRAY = new Variant[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temperate (brown-orange) frog.
|
||||||
|
@@ -88,7 +89,7 @@ public interface Frog extends Animals {
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static Variant[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.FROG_VARIANT).toArray(new Variant[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.FROG_VARIANT).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Villager.java b/src/main/java/org/bukkit/entity/Villager.java
|
||||||
|
index 9c722a762c88a88bb5ef18c3b9eab8b371360dac..127bc2aab7fb36df206d53f3e6042bb6c920878e 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Villager.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Villager.java
|
||||||
|
@@ -170,6 +170,7 @@ public interface Villager extends AbstractVillager {
|
||||||
|
* in.
|
||||||
|
*/
|
||||||
|
interface Type extends OldEnum<Type>, Keyed {
|
||||||
|
+ Type[] EMPTY_ARRAY = new Type[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
Type DESERT = getType("desert");
|
||||||
|
Type JUNGLE = getType("jungle");
|
||||||
|
@@ -204,7 +205,7 @@ public interface Villager extends AbstractVillager {
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static Type[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.VILLAGER_TYPE).toArray(new Type[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.VILLAGER_TYPE).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -213,6 +214,7 @@ public interface Villager extends AbstractVillager {
|
||||||
|
* Villagers have different trading options depending on their profession,
|
||||||
|
*/
|
||||||
|
interface Profession extends OldEnum<Profession>, Keyed, net.kyori.adventure.translation.Translatable {
|
||||||
|
+ Profession[] EMPTY_ARRAY = new Profession[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
Profession NONE = getProfession("none");
|
||||||
|
/**
|
||||||
|
@@ -311,7 +313,7 @@ public interface Villager extends AbstractVillager {
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static Profession[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.VILLAGER_PROFESSION).toArray(new Profession[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.VILLAGER_PROFESSION).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paper start
|
||||||
|
diff --git a/src/main/java/org/bukkit/map/MapCursor.java b/src/main/java/org/bukkit/map/MapCursor.java
|
||||||
|
index 7f5682c80ff25142e7c8fa14e03b4a62fc5c01d3..5fbcdf637b1e0162276e668d9ebe4a8648a29b8a 100644
|
||||||
|
--- a/src/main/java/org/bukkit/map/MapCursor.java
|
||||||
|
+++ b/src/main/java/org/bukkit/map/MapCursor.java
|
||||||
|
@@ -286,6 +286,7 @@ public final class MapCursor {
|
||||||
|
* resource pack.
|
||||||
|
*/
|
||||||
|
public interface Type extends OldEnum<Type>, Keyed {
|
||||||
|
+ Type[] EMPTY_ARRAY = new Type[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
Type PLAYER = getType("player");
|
||||||
|
Type FRAME = getType("frame");
|
||||||
|
@@ -387,7 +388,7 @@ public final class MapCursor {
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
|
||||||
|
static Type[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.MAP_DECORATION_TYPE).toArray(new Type[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.MAP_DECORATION_TYPE).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
index 2f8d3b7a5b25e323f892d2ec5eb7c3412a816ea4..22e358f7a83d84745c32ff9f04d79d51d8d92131 100644
|
||||||
|
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
@@ -47,6 +47,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
@Deprecated(forRemoval = true) // Paper - This implementation may be replaced in a future version of Paper.
|
||||||
|
// Plugins may still reflect into this class to modify permission logic for the time being.
|
||||||
|
public final class SimplePluginManager implements PluginManager {
|
||||||
|
+ public static final Plugin[] EMPTY_PLUGIN = new Plugin[0]; // Plazma - Reduce allocations
|
||||||
|
private final Server server;
|
||||||
|
private final Map<Pattern, PluginLoader> fileAssociations = new HashMap<Pattern, PluginLoader>();
|
||||||
|
private final List<Plugin> plugins = new ArrayList<Plugin>();
|
||||||
|
@@ -133,7 +134,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||||
|
this.server.getLogger().log(Level.SEVERE, "Plugin loading error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- return pluginList.toArray(new Plugin[0]);
|
||||||
|
+ return pluginList.toArray(EMPTY_PLUGIN); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
Preconditions.checkArgument(directory != null, "Directory cannot be null");
|
||||||
|
Preconditions.checkArgument(directory.isDirectory(), "Directory must be a directory");
|
||||||
|
diff --git a/src/main/java/org/bukkit/potion/PotionEffectType.java b/src/main/java/org/bukkit/potion/PotionEffectType.java
|
||||||
|
index e4cfdc80c9e49fc7992183022bdf2f36aae0d95a..0cd7987e935e2b7ede759af3db9af04366930e19 100644
|
||||||
|
--- a/src/main/java/org/bukkit/potion/PotionEffectType.java
|
||||||
|
+++ b/src/main/java/org/bukkit/potion/PotionEffectType.java
|
||||||
|
@@ -19,6 +19,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
*/
|
||||||
|
public abstract class PotionEffectType implements Keyed, Translatable, net.kyori.adventure.translation.Translatable, io.papermc.paper.world.flag.FeatureDependant { // Paper - implement Translatable & feature flag API
|
||||||
|
private static final BiMap<Integer, PotionEffectType> ID_MAP = HashBiMap.create();
|
||||||
|
+ private static final PotionEffectType[] EMPTY_ARRAY = new PotionEffectType[0]; // Plazma - Reduce allocations
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increases movement speed.
|
||||||
|
@@ -358,7 +359,7 @@ public abstract class PotionEffectType implements Keyed, Translatable, net.kyori
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.20.3")
|
||||||
|
public static PotionEffectType[] values() {
|
||||||
|
- return Lists.newArrayList(Registry.EFFECT).toArray(new PotionEffectType[0]);
|
||||||
|
+ return Lists.newArrayList(Registry.EFFECT).toArray(EMPTY_ARRAY); // Plazma - Reduce allocations
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paper start
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/Constants.java b/src/main/java/org/plazmamc/plazma/Constants.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..137f4f511998828476c2ac408a9a76289a44d071
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/Constants.java
|
||||||
|
@@ -0,0 +1,7 @@
|
||||||
|
+package org.plazmamc.plazma;
|
||||||
|
+
|
||||||
|
+public interface Constants {
|
||||||
|
+
|
||||||
|
+ int[] ZERO_INT_ARRAY = new int[]{0};
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/constants/Null.java b/src/main/java/org/plazmamc/plazma/constants/Null.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..6018a9230d0d92e23f09cc5b5cc042446bed9962
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/constants/Null.java
|
||||||
|
@@ -0,0 +1,25 @@
|
||||||
|
+package org.plazmamc.plazma.constants;
|
||||||
|
+
|
||||||
|
+import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
+import java.net.URL;
|
||||||
|
+import java.util.concurrent.CompletableFuture;
|
||||||
|
+import java.util.regex.Pattern;
|
||||||
|
+
|
||||||
|
+public interface Null {
|
||||||
|
+
|
||||||
|
+ byte[] BYTE = new byte[0];
|
||||||
|
+ short[] SHORT = new short[0];
|
||||||
|
+ int[] INT = new int[0];
|
||||||
|
+ long[] LONG = new long[0];
|
||||||
|
+
|
||||||
|
+ Object[] OBJECT = new Object[0];
|
||||||
|
+ String[] STRING = new String[0];
|
||||||
|
+ URL[] URL = new URL[0];
|
||||||
|
+ Pattern[] REGEX = new Pattern[0];
|
||||||
|
+
|
||||||
|
+ BaseComponent[] COMPONENT = new BaseComponent[0];
|
||||||
|
+
|
||||||
|
+ @SuppressWarnings("rawtypes")
|
||||||
|
+ CompletableFuture[] FUTURE = new CompletableFuture[0];
|
||||||
|
+
|
||||||
|
+}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||||
|
Date: Mon, 10 Jun 2024 12:27:08 -0300
|
||||||
|
Subject: [PATCH] Add ClientboundPacketPreDispatchEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/sparklypower/sparklypaper/event/packet/ClientboundPacketPreDispatchEvent.java b/src/main/java/net/sparklypower/sparklypaper/event/packet/ClientboundPacketPreDispatchEvent.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..9a279ad0b0f9b63f5f3a37977076e0bb805cd56d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/sparklypower/sparklypaper/event/packet/ClientboundPacketPreDispatchEvent.java
|
||||||
|
@@ -0,0 +1,79 @@
|
||||||
|
+package net.sparklypower.sparklypaper.event.packet;
|
||||||
|
+
|
||||||
|
+import org.bukkit.entity.Player;
|
||||||
|
+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;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called before a packet is dispatched to a connection.
|
||||||
|
+ * <p>
|
||||||
|
+ * Compared to other solutions like ProtocolLib, this has the advantage that this is called eariler on the packet sending cycle, before the packet is added to the packet queue, allowing for
|
||||||
|
+ * main thread access of resources without worrying about race conditions.
|
||||||
|
+ * <p>
|
||||||
|
+ * The asynchronously state of this event is undefined, the event may be called on an async or on a sync thread, depending on where the packet was sent.
|
||||||
|
+ */
|
||||||
|
+public class ClientboundPacketPreDispatchEvent extends Event implements Cancellable {
|
||||||
|
+ private static final HandlerList handlers = new HandlerList();
|
||||||
|
+ private boolean isCancelled = false;
|
||||||
|
+ private final Player player;
|
||||||
|
+ private Object packet;
|
||||||
|
+
|
||||||
|
+ public ClientboundPacketPreDispatchEvent(boolean isAsync, @Nullable Player player, @NotNull Object packet) {
|
||||||
|
+ super(isAsync);
|
||||||
|
+ this.player = player;
|
||||||
|
+ this.packet = packet;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the player associated with this packet.
|
||||||
|
+ * <p>
|
||||||
|
+ * Depending on which phase the packet is from, the player may be null
|
||||||
|
+ *
|
||||||
|
+ * @return the player associated with this packet
|
||||||
|
+ */
|
||||||
|
+ @Nullable
|
||||||
|
+ public Player getPlayer() {
|
||||||
|
+ return player;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the packet associated with this event.
|
||||||
|
+ *
|
||||||
|
+ * @return the packet associated with this event
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public Object getPacket() {
|
||||||
|
+ return packet;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Sets the packet associated with this event.
|
||||||
|
+ */
|
||||||
|
+ public void setPacket(@NotNull Object packet) {
|
||||||
|
+ this.packet = packet;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public HandlerList getHandlers() {
|
||||||
|
+ return handlers;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ public static HandlerList getHandlerList() {
|
||||||
|
+ return handlers;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCancelled() {
|
||||||
|
+ return isCancelled;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setCancelled(boolean cancel) {
|
||||||
|
+ this.isCancelled = cancel;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||||
|
Date: Mon, 10 Jun 2024 14:38:59 -0300
|
||||||
|
Subject: [PATCH] Add PlayerBlockDestroySpeedEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/sparklypower/sparklypaper/event/block/PlayerBlockDestroySpeedEvent.java b/src/main/java/net/sparklypower/sparklypaper/event/block/PlayerBlockDestroySpeedEvent.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..d5e097dad04ed62088aade42ba59866029369326
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/sparklypower/sparklypaper/event/block/PlayerBlockDestroySpeedEvent.java
|
||||||
|
@@ -0,0 +1,64 @@
|
||||||
|
+package net.sparklypower.sparklypaper.event.block;
|
||||||
|
+
|
||||||
|
+import org.bukkit.block.Block;
|
||||||
|
+import org.bukkit.entity.Player;
|
||||||
|
+import org.bukkit.event.Event;
|
||||||
|
+import org.bukkit.event.HandlerList;
|
||||||
|
+import org.bukkit.event.block.BlockEvent;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called when the block destroy speed is calculated for a block that a player is breaking.
|
||||||
|
+ * <p>
|
||||||
|
+ * Useful for custom blocks to override a server side block destroy speed to fix desynchronization issues between the server and the client. (Example: Chiseled bookshelves on the server side that are overriden by target blocks on the client side)
|
||||||
|
+ * <p>
|
||||||
|
+ * Keep in mind that you should use this event to synchronize the block destroy speed between the server and the client! Not keeping both destroy speeds in sync will cause desync issues!
|
||||||
|
+ */
|
||||||
|
+public class PlayerBlockDestroySpeedEvent extends BlockEvent {
|
||||||
|
+ private static final HandlerList handlers = new HandlerList();
|
||||||
|
+ private final Player player;
|
||||||
|
+ private float destroySpeed;
|
||||||
|
+
|
||||||
|
+ public PlayerBlockDestroySpeedEvent(@NotNull Player player, @NotNull Block block, float destroySpeed) {
|
||||||
|
+ super(block);
|
||||||
|
+ this.player = player;
|
||||||
|
+ this.destroySpeed = destroySpeed;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public HandlerList getHandlers() {
|
||||||
|
+ return handlers;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ public static HandlerList getHandlerList() {
|
||||||
|
+ return handlers;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the Player that is breaking the block involved in this event.
|
||||||
|
+ *
|
||||||
|
+ * @return The Player that is breaking the block involved in this event
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public Player getPlayer() {
|
||||||
|
+ return player;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the block destroy speed of the block involved in this event.
|
||||||
|
+ *
|
||||||
|
+ * @return the block destroy speed of the block involved in this event.
|
||||||
|
+ */
|
||||||
|
+ public float getDestroySpeed() {
|
||||||
|
+ return destroySpeed;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Sets the block destroy speed of the block involved in this event.
|
||||||
|
+ */
|
||||||
|
+ public void setDestroySpeed(float destroySpeed) {
|
||||||
|
+ this.destroySpeed = destroySpeed;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||||
|
Date: Tue, 25 Jun 2024 02:54:47 -0300
|
||||||
|
Subject: [PATCH] Add CraftItemRecipeEvent
|
||||||
|
|
||||||
|
Used when a player OR a crafter block crafts an item, as an alternative to PrepareItemCraftEvent and CraftItemEvent, because both events are not triggered when a item is crafted from a crafter
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/sparklypower/sparklypaper/event/inventory/CraftItemRecipeEvent.java b/src/main/java/net/sparklypower/sparklypaper/event/inventory/CraftItemRecipeEvent.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..129e5244fd0928fc21d9aa7d4bc28e89c1408be0
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/sparklypower/sparklypaper/event/inventory/CraftItemRecipeEvent.java
|
||||||
|
@@ -0,0 +1,70 @@
|
||||||
|
+package net.sparklypower.sparklypaper.event.inventory;
|
||||||
|
+
|
||||||
|
+import org.bukkit.event.Cancellable;
|
||||||
|
+import org.bukkit.event.Event;
|
||||||
|
+import org.bukkit.event.HandlerList;
|
||||||
|
+import org.bukkit.inventory.*;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jetbrains.annotations.Nullable;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called when the recipe of an Item is completed inside a crafting matrix.
|
||||||
|
+ *
|
||||||
|
+ * This is an alternate version of [org.bukkit.event.inventory.CraftItemEvent], where this one is called for player crafting items and crafters.
|
||||||
|
+ */
|
||||||
|
+public class CraftItemRecipeEvent extends Event implements Cancellable {
|
||||||
|
+ private static final HandlerList handlers = new HandlerList();
|
||||||
|
+ private final Recipe recipe;
|
||||||
|
+ private final ItemStack @Nullable [] matrix;
|
||||||
|
+ private ItemStack result;
|
||||||
|
+ private boolean isCancelled = false;
|
||||||
|
+
|
||||||
|
+ public CraftItemRecipeEvent(@NotNull ItemStack @Nullable [] matrix, @NotNull Recipe recipe, @Nullable ItemStack result) {
|
||||||
|
+ this.matrix = matrix;
|
||||||
|
+ this.recipe = recipe;
|
||||||
|
+ this.result = result;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void setResult(@Nullable ItemStack result) {
|
||||||
|
+ this.result = result;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ public ItemStack getResult() {
|
||||||
|
+ return result;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * @return A copy of the current recipe on the crafting matrix.
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public Recipe getRecipe() {
|
||||||
|
+ return recipe;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public @Nullable ItemStack[] getCraftingMatrix() {
|
||||||
|
+ return matrix;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCancelled() {
|
||||||
|
+ return isCancelled;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setCancelled(boolean cancel) {
|
||||||
|
+ this.isCancelled = cancel;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public HandlerList getHandlers() {
|
||||||
|
+ return handlers;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ public static HandlerList getHandlerList() {
|
||||||
|
+ return handlers;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||||
|
Date: Mon, 10 Jun 2024 12:22:15 -0300
|
||||||
|
Subject: [PATCH] Add ClientboundPacketPreDispatchEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||||
|
index 3e550f8e7cd4f4e16f499a8a2a4b95420270f07a..3bcff05a99662c28cc490579162a1f05b55b1cda 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||||
|
@@ -450,6 +450,18 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // SparklyPaper start - Add ClientboundPacketPreDispatchEvent
|
||||||
|
+ net.minecraft.server.level.ServerPlayer serverPlayer = this.getPlayer();
|
||||||
|
+ org.bukkit.craftbukkit.entity.CraftPlayer craftPlayer = null;
|
||||||
|
+ if (serverPlayer != null)
|
||||||
|
+ craftPlayer = serverPlayer.getBukkitEntity();
|
||||||
|
+ net.sparklypower.sparklypaper.event.packet.ClientboundPacketPreDispatchEvent event = new net.sparklypower.sparklypaper.event.packet.ClientboundPacketPreDispatchEvent(!org.bukkit.Bukkit.isPrimaryThread(), craftPlayer, packet);
|
||||||
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||||
|
+ if (event.isCancelled())
|
||||||
|
+ return;
|
||||||
|
+ packet = (Packet<?>) event.getPacket();
|
||||||
|
+ // SparklyPaper end
|
||||||
|
+
|
||||||
|
packet.onPacketDispatch(this.getPlayer());
|
||||||
|
if (connected && (InnerUtil.canSendImmediate(this, packet)
|
||||||
|
|| (io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.pendingActions.isEmpty()
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||||
|
Date: Mon, 10 Jun 2024 14:39:10 -0300
|
||||||
|
Subject: [PATCH] Add PlayerBlockDestroySpeedEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||||
|
index 99fd67a78539133adf78d65e2c520ff3dd260301..96640ae707c9babe1c4f4895f39d4d7cfc71a765 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||||
|
@@ -336,6 +336,14 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||||
|
protected float getDestroyProgress(BlockState state, Player player, BlockGetter world, BlockPos pos) {
|
||||||
|
float f = state.getDestroySpeed(world, pos);
|
||||||
|
|
||||||
|
+ // SparklyPaper start - Add PlayerBlockDestroySpeedEvent
|
||||||
|
+ // *Technically* it seems that all getDestroyProgress calls use a LevelAccessor, but anyway...
|
||||||
|
+ if (world instanceof LevelAccessor) {
|
||||||
|
+ net.sparklypower.sparklypaper.event.block.PlayerBlockDestroySpeedEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBlockDestroySpeedEvent(player, (LevelAccessor) world, pos, f);
|
||||||
|
+ f = event.getDestroySpeed();
|
||||||
|
+ }
|
||||||
|
+ // SparklyPaper end
|
||||||
|
+
|
||||||
|
if (f == -1.0F) {
|
||||||
|
return 0.0F;
|
||||||
|
} else {
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
index e37aaf77f94b97b736cc20ef070cefdff0400188..a46f0c810ee2b9679c0530e5e6d3505b3d1f661c 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
@@ -2271,4 +2271,13 @@ public class CraftEventFactory {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
// Paper end - add EntityFertilizeEggEvent
|
||||||
|
+
|
||||||
|
+ // SparklyPaper start - add PlayerBlockDestroySpeedEvent
|
||||||
|
+ public static net.sparklypower.sparklypaper.event.block.PlayerBlockDestroySpeedEvent callPlayerBlockDestroySpeedEvent(net.minecraft.world.entity.player.Player player, LevelAccessor world, BlockPos blockPos, float destroySpeed) {
|
||||||
|
+ org.bukkit.block.Block block = CraftBlock.at(world, blockPos);
|
||||||
|
+ net.sparklypower.sparklypaper.event.block.PlayerBlockDestroySpeedEvent event = new net.sparklypower.sparklypaper.event.block.PlayerBlockDestroySpeedEvent((Player) player.getBukkitEntity(), block, destroySpeed);
|
||||||
|
+ event.callEvent();
|
||||||
|
+ return event;
|
||||||
|
+ }
|
||||||
|
+ // SparklyPaper end
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||||
|
Date: Tue, 25 Jun 2024 02:52:32 -0300
|
||||||
|
Subject: [PATCH] Add CraftItemRecipeEvent
|
||||||
|
|
||||||
|
Used when a player OR a crafter block crafts an item, as an alternative to PrepareItemCraftEvent and CraftItemEvent, because both events are not triggered when a item is crafted from a crafter
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
index b5d5dbc50a7b8c40739a15f164ffd08fdc534f9c..01a67fde6c823cac52a6b09720f09acc825d3f86 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
@@ -3218,6 +3218,21 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
} else {
|
||||||
|
event = new CraftItemEvent(recipe, inventory, type, packet.getSlotNum(), click, action);
|
||||||
|
}
|
||||||
|
+ // SparklyPaper start - add CraftItemRecipeEvent
|
||||||
|
+ // We will pigback a bit on the current implementation
|
||||||
|
+ net.sparklypower.sparklypaper.event.inventory.CraftItemRecipeEvent craftItemRecipeEvent = new net.sparklypower.sparklypaper.event.inventory.CraftItemRecipeEvent(
|
||||||
|
+ ((CraftingInventory) top).getMatrix(), // We cannot use the top inventory directly because (it seems) that the first slot is the "result" slot
|
||||||
|
+ recipe,
|
||||||
|
+ event.getCurrentItem()
|
||||||
|
+ );
|
||||||
|
+ if (craftItemRecipeEvent.callEvent()) {
|
||||||
|
+ event.setCurrentItem(craftItemRecipeEvent.getResult());
|
||||||
|
+ } else {
|
||||||
|
+ event.setCancelled(true);
|
||||||
|
+ cancelled = true;
|
||||||
|
+ event.setCurrentItem(craftItemRecipeEvent.getResult());
|
||||||
|
+ }
|
||||||
|
+ // SparklyPaper end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/CrafterBlock.java b/src/main/java/net/minecraft/world/level/block/CrafterBlock.java
|
||||||
|
index 0e609b1e3abd50b415d8376dc550375a8a0251b6..8dbac20e32b70879eeee1c3563948e36c2eae342 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/CrafterBlock.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/CrafterBlock.java
|
||||||
|
@@ -203,6 +203,13 @@ public class CrafterBlock extends BaseEntityBlock {
|
||||||
|
}
|
||||||
|
itemstack = CraftItemStack.asNMSCopy(event.getResult());
|
||||||
|
// CraftBukkit end
|
||||||
|
+ // SparklyPaper - add CraftItemRecipeEvent
|
||||||
|
+ net.sparklypower.sparklypaper.event.inventory.CraftItemRecipeEvent sparklyEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callCraftItemRecipeEvent(crafterblockentity, recipeholder.toBukkitRecipe(), itemstack);
|
||||||
|
+ if (sparklyEvent.isCancelled()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ itemstack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(sparklyEvent.getResult());
|
||||||
|
+ // SparklyPaper end
|
||||||
|
if (itemstack.isEmpty()) {
|
||||||
|
world.levelEvent(1050, pos, 0);
|
||||||
|
} else {
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
index a46f0c810ee2b9679c0530e5e6d3505b3d1f661c..85926a55066ac793b2e4cfe3502f9ab201df91a3 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
@@ -1471,6 +1471,24 @@ public class CraftEventFactory {
|
||||||
|
Bukkit.getPluginManager().callEvent(crafterCraftEvent);
|
||||||
|
return crafterCraftEvent;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // SparklyPaper start - add CraftItemRecipeEvent
|
||||||
|
+ public static net.sparklypower.sparklypaper.event.inventory.CraftItemRecipeEvent callCraftItemRecipeEvent(net.minecraft.world.inventory.CraftingContainer container, Recipe recipe, ItemStack result) {
|
||||||
|
+ org.bukkit.inventory.ItemStack[] matrix = new org.bukkit.inventory.ItemStack[container.getItems().size()];
|
||||||
|
+ int i = 0;
|
||||||
|
+ for (ItemStack item : container.getItems()) {
|
||||||
|
+ matrix[i] = CraftItemStack.asCraftMirror(item);
|
||||||
|
+ i++;
|
||||||
|
+ }
|
||||||
|
+ org.bukkit.inventory.ItemStack bukkitResult = CraftItemStack.asCraftMirror(result);
|
||||||
|
+
|
||||||
|
+ net.sparklypower.sparklypaper.event.inventory.CraftItemRecipeEvent event = new net.sparklypower.sparklypaper.event.inventory.CraftItemRecipeEvent(matrix, recipe, bukkitResult);
|
||||||
|
+ Bukkit.getPluginManager().callEvent(event);
|
||||||
|
+
|
||||||
|
+ return event;
|
||||||
|
+ }
|
||||||
|
+ // SparklyPaper end
|
||||||
|
+
|
||||||
|
// Paper start
|
||||||
|
@Deprecated
|
||||||
|
public static com.destroystokyo.paper.event.entity.ProjectileCollideEvent callProjectileCollideEvent(Entity entity, EntityHitResult position) {
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: granny <contact@granny.dev>
|
|
||||||
Date: Thu, 18 Jan 2024 21:01:12 +0900
|
|
||||||
Subject: [PATCH] Purpur Generated API Changes
|
|
||||||
|
|
||||||
PurpurMC
|
|
||||||
Copyright (C) 2024 PurpurMC
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
||||||
diff --git a/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
||||||
index 0241146..2718c0e 100644
|
|
||||||
--- a/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
||||||
+++ b/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
||||||
@@ -436,6 +436,18 @@ public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
|
||||||
|
|
||||||
GoalKey<Zombie> ZOMBIE_ATTACK_TURTLE_EGG = create("zombie_attack_turtle_egg", Zombie.class);
|
|
||||||
|
|
||||||
+ // Purpur start
|
|
||||||
+ GoalKey<Mob> MOB_HAS_RIDER = GoalKey.of(Mob.class, NamespacedKey.minecraft("has_rider"));
|
|
||||||
+ GoalKey<AbstractHorse> HORSE_HAS_RIDER = GoalKey.of(AbstractHorse.class, NamespacedKey.minecraft("horse_has_rider"));
|
|
||||||
+ GoalKey<Llama> LLAMA_HAS_RIDER = GoalKey.of(Llama.class, NamespacedKey.minecraft("llama_has_rider"));
|
|
||||||
+ GoalKey<Phantom> FIND_CRYSTAL = GoalKey.of(Phantom.class, NamespacedKey.minecraft("find_crystal"));
|
|
||||||
+ GoalKey<Phantom> ORBIT_CRYSTAL = GoalKey.of(Phantom.class, NamespacedKey.minecraft("orbit_crystal"));
|
|
||||||
+ GoalKey<Drowned> DROWNED_ATTACK_VILLAGER = GoalKey.of(Drowned.class, NamespacedKey.minecraft("drowned_attack_villager"));
|
|
||||||
+ GoalKey<Zombie> ZOMBIE_ATTACK_VILLAGER = GoalKey.of(Zombie.class, NamespacedKey.minecraft("zombie_attack_villager"));
|
|
||||||
+ GoalKey<Wolf> AVOID_RABID_WOLF = GoalKey.of(Wolf.class, NamespacedKey.minecraft("avoid_rabid_wolf"));
|
|
||||||
+ GoalKey<IronGolem> RECEIVE_FLOWER = GoalKey.of(IronGolem.class, NamespacedKey.minecraft("receive_flower"));
|
|
||||||
+ // Purpur end
|
|
||||||
+
|
|
||||||
private static <T extends Mob> @NonNull GoalKey<T> create(final @NonNull String key,
|
|
||||||
final @NonNull Class<T> type) {
|
|
||||||
return GoalKey.of(type, NamespacedKey.minecraft(key));
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Fri, 25 Oct 2024 14:10:19 +0900
|
|
||||||
Subject: [PATCH] fixup
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
||||||
index 02411466bdcf4ff731f01ccebb2c99942e0db878..2718c0e5061838b01881bb231c53f4da348adce3 100644
|
|
||||||
--- a/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
||||||
+++ b/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
||||||
@@ -436,6 +436,18 @@ public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
|
||||||
|
|
||||||
GoalKey<Zombie> ZOMBIE_ATTACK_TURTLE_EGG = create("zombie_attack_turtle_egg", Zombie.class);
|
|
||||||
|
|
||||||
+ // Purpur start
|
|
||||||
+ GoalKey<Mob> MOB_HAS_RIDER = GoalKey.of(Mob.class, NamespacedKey.minecraft("has_rider"));
|
|
||||||
+ GoalKey<AbstractHorse> HORSE_HAS_RIDER = GoalKey.of(AbstractHorse.class, NamespacedKey.minecraft("horse_has_rider"));
|
|
||||||
+ GoalKey<Llama> LLAMA_HAS_RIDER = GoalKey.of(Llama.class, NamespacedKey.minecraft("llama_has_rider"));
|
|
||||||
+ GoalKey<Phantom> FIND_CRYSTAL = GoalKey.of(Phantom.class, NamespacedKey.minecraft("find_crystal"));
|
|
||||||
+ GoalKey<Phantom> ORBIT_CRYSTAL = GoalKey.of(Phantom.class, NamespacedKey.minecraft("orbit_crystal"));
|
|
||||||
+ GoalKey<Drowned> DROWNED_ATTACK_VILLAGER = GoalKey.of(Drowned.class, NamespacedKey.minecraft("drowned_attack_villager"));
|
|
||||||
+ GoalKey<Zombie> ZOMBIE_ATTACK_VILLAGER = GoalKey.of(Zombie.class, NamespacedKey.minecraft("zombie_attack_villager"));
|
|
||||||
+ GoalKey<Wolf> AVOID_RABID_WOLF = GoalKey.of(Wolf.class, NamespacedKey.minecraft("avoid_rabid_wolf"));
|
|
||||||
+ GoalKey<IronGolem> RECEIVE_FLOWER = GoalKey.of(IronGolem.class, NamespacedKey.minecraft("receive_flower"));
|
|
||||||
+ // Purpur end
|
|
||||||
+
|
|
||||||
private static <T extends Mob> @NonNull GoalKey<T> create(final @NonNull String key,
|
|
||||||
final @NonNull Class<T> type) {
|
|
||||||
return GoalKey.of(type, NamespacedKey.minecraft(key));
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,124 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 14 Jan 2024 19:51:19 +0900
|
|
||||||
Subject: [PATCH] Build System Changes
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
||||||
index 535b0c6a750cc77fb9340d6e080932f3eb3bde17..3bb91f4d0447fc283c56ffab24cb8e203925ebad 100644
|
|
||||||
--- a/build.gradle.kts
|
|
||||||
+++ b/build.gradle.kts
|
|
||||||
@@ -13,70 +13,29 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
|
|
||||||
val alsoShade: Configuration by configurations.creating
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
- implementation(project(":purpur-api")) // Pufferfish // Paper // Purpur
|
|
||||||
- // Paper start
|
|
||||||
- implementation("org.jline:jline-terminal-jansi:3.21.0")
|
|
||||||
- implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
|
||||||
- implementation("net.kyori:adventure-text-serializer-ansi:4.17.0") // Keep in sync with adventureVersion from Paper-API build file
|
|
||||||
- /*
|
|
||||||
- Required to add the missing Log4j2Plugins.dat file from log4j-core
|
|
||||||
- which has been removed by Mojang. Without it, log4j has to classload
|
|
||||||
- all its classes to check if they are plugins.
|
|
||||||
- Scanning takes about 1-2 seconds so adding this speeds up the server start.
|
|
||||||
- */
|
|
||||||
- implementation("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - implementation
|
|
||||||
- log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins
|
|
||||||
- runtimeOnly(log4jPlugins.output)
|
|
||||||
- alsoShade(log4jPlugins.output)
|
|
||||||
- implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol
|
|
||||||
- // Paper end
|
|
||||||
- implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion
|
|
||||||
- implementation("org.ow2.asm:asm-commons:9.7.1")
|
|
||||||
- implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
|
|
||||||
- implementation("commons-lang:commons-lang:2.6")
|
|
||||||
- runtimeOnly("org.xerial:sqlite-jdbc:3.46.0.0")
|
|
||||||
- runtimeOnly("com.mysql:mysql-connector-j:8.4.0")
|
|
||||||
- runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
|
|
||||||
- // Paper start - Use Velocity cipher
|
|
||||||
- implementation("com.velocitypowered:velocity-native:3.3.0-SNAPSHOT") {
|
|
||||||
- isTransitive = false
|
|
||||||
- }
|
|
||||||
- // Paper end - Use Velocity cipher
|
|
||||||
-
|
|
||||||
- runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.6")
|
|
||||||
- runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
|
|
||||||
- runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
|
||||||
-
|
|
||||||
- // Pufferfish start
|
|
||||||
- implementation("org.yaml:snakeyaml:1.32")
|
|
||||||
- implementation ("com.github.carleslc.Simple-YAML:Simple-Yaml:1.8.4") { // Purpur
|
|
||||||
- exclude(group="org.yaml", module="snakeyaml")
|
|
||||||
- }
|
|
||||||
- // Pufferfish end
|
|
||||||
-
|
|
||||||
- implementation("org.mozilla:rhino-runtime:1.7.14") // Purpur
|
|
||||||
- implementation("org.mozilla:rhino-engine:1.7.14") // Purpur
|
|
||||||
- implementation("dev.omega24:upnp4j:1.0") // Purpur
|
|
||||||
-
|
|
||||||
- testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test
|
|
||||||
- testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
|
||||||
- testImplementation("org.junit.platform:junit-platform-suite-engine:1.10.0")
|
|
||||||
- testImplementation("org.hamcrest:hamcrest:2.2")
|
|
||||||
- testImplementation("org.mockito:mockito-core:5.14.1")
|
|
||||||
- testImplementation("org.ow2.asm:asm-tree:9.7.1")
|
|
||||||
- testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest
|
|
||||||
- implementation("net.neoforged:srgutils:1.0.9") // Paper - mappings handling
|
|
||||||
- implementation("net.neoforged:AutoRenamingTool:2.0.3") // Paper - remap plugins
|
|
||||||
- // Paper start - Remap reflection
|
|
||||||
- val reflectionRewriterVersion = "0.0.3"
|
|
||||||
- implementation("io.papermc:reflection-rewriter:$reflectionRewriterVersion")
|
|
||||||
- implementation("io.papermc:reflection-rewriter-runtime:$reflectionRewriterVersion")
|
|
||||||
- implementation("io.papermc:reflection-rewriter-proxy-generator:$reflectionRewriterVersion")
|
|
||||||
- // Paper end - Remap reflection
|
|
||||||
- // Paper start - spark
|
|
||||||
- implementation("me.lucko:spark-api:0.1-20240720.200737-2")
|
|
||||||
- implementation("me.lucko:spark-paper:1.10.105-SNAPSHOT")
|
|
||||||
- // Paper end - spark
|
|
||||||
+ // Plazma start - Build System Changes
|
|
||||||
+ implementation(project(":${rootProject.providers.gradleProperty("brandName").get().lowercase()}-api"))
|
|
||||||
+ implementation(common.snakeyaml)
|
|
||||||
+ implementation(common.asm.commons)
|
|
||||||
+ implementation(common.log4j.core)
|
|
||||||
+ implementation(common.log4j.iostreams)
|
|
||||||
+ implementation(common.commons.lang2)
|
|
||||||
+ implementation(common.adventure.serializer.ansi)
|
|
||||||
+ implementation(server.velocity) { isTransitive = false }
|
|
||||||
+ implementation(server.simpleyaml) { exclude(group="org.yaml", module="snakeyaml") }
|
|
||||||
+ implementation(server.bundles.implementation)
|
|
||||||
+
|
|
||||||
+ log4jPlugins.annotationProcessorConfigurationName(common.log4j.core)
|
|
||||||
+ alsoShade(log4jPlugins.output) // Plazma - Diff on patch
|
|
||||||
+ runtimeOnly(log4jPlugins.output) // Plazma - Diff on patch
|
|
||||||
+
|
|
||||||
+ runtimeOnly(common.maven.provider)
|
|
||||||
+ runtimeOnly(common.bundles.maven)
|
|
||||||
+ runtimeOnly(server.bundles.runtime)
|
|
||||||
+
|
|
||||||
+ testImplementation(common.bundles.test)
|
|
||||||
+ testImplementation(server.bundles.test)
|
|
||||||
+ // Plazma end - Build System Changes
|
|
||||||
}
|
|
||||||
|
|
||||||
paperweight {
|
|
||||||
@@ -104,14 +63,14 @@ tasks.jar {
|
|
||||||
val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
|
|
||||||
attributes(
|
|
||||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
|
||||||
- "Implementation-Title" to "Purpur", // Pufferfish // Purpur
|
|
||||||
+ "Implementation-Title" to rootProject.providers.gradleProperty("brandName").get(), // Pufferfish // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
"Implementation-Version" to implementationVersion,
|
|
||||||
"Implementation-Vendor" to date, // Paper
|
|
||||||
- "Specification-Title" to "Purpur", // Pufferfish // Purpur
|
|
||||||
+ "Specification-Title" to rootProject.providers.gradleProperty("brandName").get(), // Pufferfish // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
"Specification-Version" to project.version,
|
|
||||||
- "Specification-Vendor" to "Purpur Team", // Pufferfish // Purpur
|
|
||||||
- "Brand-Id" to "purpurmc:purpur", // Pufferfish // Purpur
|
|
||||||
- "Brand-Name" to "Purpur", // Pufferfish // Purpur
|
|
||||||
+ "Specification-Vendor" to rootProject.providers.gradleProperty("providerName").get(), // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
+ "Brand-Id" to rootProject.providers.gradleProperty("brandKey").get(), // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
+ "Brand-Name" to rootProject.providers.gradleProperty("brandName").get(), // Pufferfish // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
"Build-Number" to (build ?: ""),
|
|
||||||
"Build-Time" to Instant.now().toString(),
|
|
||||||
"Git-Branch" to gitBranch, // Paper
|
|
||||||
@@ -1,442 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Wed, 21 Dec 2022 19:31:24 +0900
|
|
||||||
Subject: [PATCH] Fork-friendly Rebranding
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
||||||
index 8cde30544e14f8fc2dac32966ae3c21f8cf3a551..81b204c03b3c9a997f00fd423daa963757cb0daf 100644
|
|
||||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
||||||
@@ -593,7 +593,7 @@ public class Metrics {
|
|
||||||
boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
|
||||||
// Only start Metrics, if it's enabled in the config
|
|
||||||
if (config.getBoolean("enabled", true)) {
|
|
||||||
- Metrics metrics = new Metrics("Purpur", serverUUID, logFailedRequests, Bukkit.getLogger()); // Pufferfish // Purpur
|
|
||||||
+ Metrics metrics = new Metrics(io.papermc.paper.ServerBuildInfo.buildInfo().brandName(), serverUUID, logFailedRequests, Bukkit.getLogger()); // Pufferfish // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
|
||||||
String minecraftVersion = Bukkit.getVersion();
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
|
||||||
index 6d36fc6d8e22d9b68dea3830f6ecc8763184c343..6995627310de4911d87a2f93a723d6b93dc0612f 100644
|
|
||||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
|
||||||
@@ -36,7 +36,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
||||||
private static final int DISTANCE_ERROR = -1;
|
|
||||||
private static final int DISTANCE_UNKNOWN = -2;
|
|
||||||
// Purpur start
|
|
||||||
- private static final String DOWNLOAD_PAGE = "https://purpurmc.org/downloads";
|
|
||||||
+ // private static final String DOWNLOAD_PAGE = "https://purpurmc.org/downloads"; // Plazma - Fork-friendly Rebranding
|
|
||||||
private static int distance = DISTANCE_UNKNOWN; public int distance() { return distance; }
|
|
||||||
// Purpur end
|
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
||||||
if (build.buildNumber().isEmpty() && build.gitCommit().isEmpty()) {
|
|
||||||
updateMessage = text("You are running a development version without access to version information", color(0xFF5300));
|
|
||||||
} else {
|
|
||||||
- updateMessage = getUpdateStatusMessage("PurpurMC/Purpur", build); // Purpur
|
|
||||||
+ updateMessage = getUpdateStatusMessage("PlazmaMC/Plazma", build); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
final @Nullable Component history = this.getHistory();
|
|
||||||
|
|
||||||
@@ -63,8 +63,12 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
||||||
//int distance = DISTANCE_ERROR; // Purpur - use field
|
|
||||||
|
|
||||||
final OptionalInt buildNumber = build.buildNumber();
|
|
||||||
- if (buildNumber.isPresent()) {
|
|
||||||
- distance = fetchDistanceFromSiteApi(build, buildNumber.getAsInt());
|
|
||||||
+ // Plazma start - TODO: CI Checking
|
|
||||||
+ //noinspection PointlessBooleanExpression
|
|
||||||
+ if (false && buildNumber.isPresent()) {
|
|
||||||
+ throw new UnsupportedOperationException("Version fetching from CI is not supported yet");
|
|
||||||
+ // distance = fetchDistanceFromSiteApi(build, buildNumber.getAsInt());
|
|
||||||
+ // Plazma end - TODO: CI Checking
|
|
||||||
} else {
|
|
||||||
final Optional<String> gitBranch = build.gitBranch();
|
|
||||||
final Optional<String> gitCommit = build.gitCommit();
|
|
||||||
@@ -80,12 +84,13 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
||||||
default -> text("* You are " + distance + " version(s) behind", NamedTextColor.YELLOW) // Purpur
|
|
||||||
.append(Component.newline())
|
|
||||||
.append(text("Download the new version at: ")
|
|
||||||
- .append(text(DOWNLOAD_PAGE, NamedTextColor.GOLD)
|
|
||||||
+ .append(text(io.papermc.paper.ServerBrandConstants.DOWNLOAD_PAGE, NamedTextColor.GOLD) // Plazma - Fork-friendly Rebranding
|
|
||||||
.hoverEvent(text("Click to open", NamedTextColor.WHITE))
|
|
||||||
- .clickEvent(ClickEvent.openUrl(DOWNLOAD_PAGE))));
|
|
||||||
+ .clickEvent(ClickEvent.openUrl(io.papermc.paper.ServerBrandConstants.DOWNLOAD_PAGE)))); // Plazma - Fork-friendly Rebranding
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* // Plazma - TODO: CI Checking
|
|
||||||
private static int fetchDistanceFromSiteApi(final ServerBuildInfo build, final int jenkinsBuild) {
|
|
||||||
try {
|
|
||||||
try (final BufferedReader reader = Resources.asCharSource(
|
|
||||||
@@ -105,6 +110,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
||||||
return DISTANCE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ */ // Plazma - TODO: CI Checking
|
|
||||||
|
|
||||||
// Contributed by Techcable <Techcable@outlook.com> in GH-65
|
|
||||||
private static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) {
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
||||||
index 90b352647..02f6a4947 100644
|
|
||||||
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
||||||
@@ -20,7 +20,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
|
|
||||||
@Override
|
|
||||||
protected LineReader buildReader(LineReaderBuilder builder) {
|
|
||||||
builder
|
|
||||||
- .appName("Purpur") // Purpur
|
|
||||||
+ .appName(io.papermc.paper.ServerBuildInfo.buildInfo().brandName()) // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
|
|
||||||
.completer(new ConsoleCommandCompleter(this.server))
|
|
||||||
.option(LineReader.Option.COMPLETE_IN_WORD, true);
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/ServerBrandConstants.java b/src/main/java/io/papermc/paper/ServerBrandConstants.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..af534fb15be2be3e5b4258c522e0e6c967c2bb1c
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/ServerBrandConstants.java
|
|
||||||
@@ -0,0 +1,33 @@
|
|
||||||
+package io.papermc.paper;
|
|
||||||
+
|
|
||||||
+import org.jetbrains.annotations.Nullable;
|
|
||||||
+
|
|
||||||
+public enum ServerBrandConstants {;
|
|
||||||
+
|
|
||||||
+ // Basic brand informations
|
|
||||||
+ public static final String BRAND_NAME = "Plazma";
|
|
||||||
+ public static final String RESOURCE_PATH = "META-INF/maven/org.plazmamc.plazma/plazma-api/pom.properties";
|
|
||||||
+
|
|
||||||
+ @Nullable
|
|
||||||
+ public static final String ASCII_LOGO = """
|
|
||||||
+
|
|
||||||
+ \033[38;2;215;23;133m█\033[38;2;212;24;134m█\033[38;2;209;26;134m█\033[38;2;205;27;135m█\033[38;2;202;28;136m█\033[38;2;199;30;136m█\033[38;2;196;31;137m╗\033[38;2;193;33;138m \033[38;2;190;34;138m█\033[38;2;186;35;139m█\033[38;2;183;37;140m╗\033[38;2;180;38;140m \033[38;2;177;39;141m \033[38;2;174;41;142m \033[38;2;170;42;142m \033[38;2;167;43;143m \033[38;2;164;45;144m \033[38;2;161;46;144m█\033[38;2;158;47;145m█\033[38;2;155;49;146m█\033[38;2;151;50;146m█\033[38;2;148;52;147m█\033[38;2;145;53;148m╗\033[38;2;142;54;148m \033[38;2;139;56;149m█\033[38;2;135;57;149m█\033[38;2;132;58;150m█\033[38;2;129;60;151m█\033[38;2;126;61;151m█\033[38;2;123;62;152m█\033[38;2;120;64;153m█\033[38;2;116;65;153m╗ \033[38;2;113;67;154m█\033[38;2;110;68;155m█\033[38;2;107;69;155m█\033[38;2;104;71;156m╗\033[38;2;101;72;157m \033[38;2;97;73;157m \033[38;2;94;75;158m \033[38;2;91;76;159m█\033[38;2;88;77;159m█\033[38;2;85;79;160m█\033[38;2;81;80;161m╗ \033[38;2;78;81;161m \033[38;2;75;83;162m█\033[38;2;72;84;163m█\033[38;2;69;86;163m█\033[38;2;66;87;164m█\033[38;2;62;88;165m█\033[38;2;59;90;165m╗\033[38;2;56;91;166m\s
|
|
||||||
+ \033[38;2;215;23;133m█\033[38;2;212;24;134m█\033[38;2;209;26;134m╔\033[38;2;205;27;135m═\033[38;2;202;28;136m═\033[38;2;199;30;136m█\033[38;2;196;31;137m█\033[38;2;193;33;138m╗ \033[38;2;190;34;138m█\033[38;2;186;35;139m█\033[38;2;183;37;140m║\033[38;2;180;38;140m \033[38;2;177;39;141m \033[38;2;174;41;142m \033[38;2;170;42;142m \033[38;2;167;43;143m \033[38;2;164;45;144m█\033[38;2;161;46;144m█\033[38;2;158;47;145m╔\033[38;2;155;49;146m═\033[38;2;151;50;146m═\033[38;2;148;52;147m█\033[38;2;145;53;148m█\033[38;2;142;54;148m╗ \033[38;2;139;56;149m╚\033[38;2;135;57;149m═\033[38;2;132;58;150m═\033[38;2;129;60;151m█\033[38;2;126;61;151m█\033[38;2;123;62;152m█\033[38;2;120;64;153m╔\033[38;2;116;65;153m╝ \033[38;2;113;67;154m█\033[38;2;110;68;155m█\033[38;2;107;69;155m█\033[38;2;104;71;156m█\033[38;2;101;72;157m╗\033[38;2;97;73;157m \033[38;2;94;75;158m█\033[38;2;91;76;159m█\033[38;2;88;77;159m█\033[38;2;85;79;160m█\033[38;2;81;80;161m║ \033[38;2;78;81;161m█\033[38;2;75;83;162m█\033[38;2;72;84;163m╔\033[38;2;69;86;163m═\033[38;2;66;87;164m═\033[38;2;62;88;165m█\033[38;2;59;90;165m█\033[38;2;56;91;166m╗
|
|
||||||
+ \033[38;2;215;23;133m█\033[38;2;212;24;134m█\033[38;2;209;26;134m█\033[38;2;205;27;135m█\033[38;2;202;28;136m█\033[38;2;199;30;136m█\033[38;2;196;31;137m╔\033[38;2;193;33;138m╝ \033[38;2;190;34;138m█\033[38;2;186;35;139m█\033[38;2;183;37;140m║\033[38;2;180;38;140m \033[38;2;177;39;141m \033[38;2;174;41;142m \033[38;2;170;42;142m \033[38;2;167;43;143m \033[38;2;164;45;144m█\033[38;2;161;46;144m█\033[38;2;158;47;145m█\033[38;2;155;49;146m█\033[38;2;151;50;146m█\033[38;2;148;52;147m█\033[38;2;145;53;148m█\033[38;2;142;54;148m║ \033[38;2;139;56;149m \033[38;2;135;57;149m \033[38;2;132;58;150m█\033[38;2;129;60;151m█\033[38;2;126;61;151m█\033[38;2;123;62;152m╔\033[38;2;120;64;153m╝\033[38;2;116;65;153m \033[38;2;113;67;154m█\033[38;2;110;68;155m█\033[38;2;107;69;155m╔\033[38;2;104;71;156m█\033[38;2;101;72;157m█\033[38;2;97;73;157m█\033[38;2;94;75;158m█\033[38;2;91;76;159m╔\033[38;2;88;77;159m█\033[38;2;85;79;160m█\033[38;2;81;80;161m║ \033[38;2;78;81;161m█\033[38;2;75;83;162m█\033[38;2;72;84;163m█\033[38;2;69;86;163m█\033[38;2;66;87;164m█\033[38;2;62;88;165m█\033[38;2;59;90;165m█\033[38;2;56;91;166m║
|
|
||||||
+ \033[38;2;215;23;133m█\033[38;2;212;24;134m█\033[38;2;209;26;134m╔\033[38;2;205;27;135m═\033[38;2;202;28;136m═\033[38;2;199;30;136m═\033[38;2;196;31;137m╝\033[38;2;193;33;138m \033[38;2;190;34;138m█\033[38;2;186;35;139m█\033[38;2;183;37;140m║\033[38;2;180;38;140m \033[38;2;177;39;141m \033[38;2;174;41;142m \033[38;2;170;42;142m \033[38;2;167;43;143m \033[38;2;164;45;144m█\033[38;2;161;46;144m█\033[38;2;158;47;145m╔\033[38;2;155;49;146m═\033[38;2;151;50;146m═\033[38;2;148;52;147m█\033[38;2;145;53;148m█\033[38;2;142;54;148m║ \033[38;2;139;56;149m \033[38;2;135;57;149m█\033[38;2;132;58;150m█\033[38;2;129;60;151m█\033[38;2;126;61;151m╔\033[38;2;123;62;152m╝\033[38;2;120;64;153m \033[38;2;116;65;153m \033[38;2;113;67;154m█\033[38;2;110;68;155m█\033[38;2;107;69;155m║\033[38;2;104;71;156m╚\033[38;2;101;72;157m█\033[38;2;97;73;157m█\033[38;2;94;75;158m╔\033[38;2;91;76;159m╝\033[38;2;88;77;159m█\033[38;2;85;79;160m█\033[38;2;81;80;161m║ \033[38;2;78;81;161m█\033[38;2;75;83;162m█\033[38;2;72;84;163m╔\033[38;2;69;86;163m═\033[38;2;66;87;164m═\033[38;2;62;88;165m█\033[38;2;59;90;165m█\033[38;2;56;91;166m║
|
|
||||||
+ \033[38;2;215;23;133m█\033[38;2;212;24;134m█\033[38;2;209;26;134m║\033[38;2;205;27;135m \033[38;2;202;28;136m \033[38;2;199;30;136m \033[38;2;196;31;137m \033[38;2;193;33;138m \033[38;2;190;34;138m█\033[38;2;186;35;139m█\033[38;2;183;37;140m█\033[38;2;180;38;140m█\033[38;2;177;39;141m█\033[38;2;174;41;142m█\033[38;2;170;42;142m█\033[38;2;167;43;143m╗ \033[38;2;164;45;144m█\033[38;2;161;46;144m█\033[38;2;158;47;145m║\033[38;2;155;49;146m \033[38;2;151;50;146m \033[38;2;148;52;147m█\033[38;2;145;53;148m█\033[38;2;142;54;148m║ \033[38;2;139;56;149m█\033[38;2;135;57;149m█\033[38;2;132;58;150m█\033[38;2;129;60;151m█\033[38;2;126;61;151m█\033[38;2;123;62;152m█\033[38;2;120;64;153m█\033[38;2;116;65;153m╗ \033[38;2;113;67;154m█\033[38;2;110;68;155m█\033[38;2;107;69;155m║\033[38;2;104;71;156m \033[38;2;101;72;157m╚\033[38;2;97;73;157m═\033[38;2;94;75;158m╝\033[38;2;91;76;159m \033[38;2;88;77;159m█\033[38;2;85;79;160m█\033[38;2;81;80;161m║ \033[38;2;78;81;161m█\033[38;2;75;83;162m█\033[38;2;72;84;163m║\033[38;2;69;86;163m \033[38;2;66;87;164m \033[38;2;62;88;165m█\033[38;2;59;90;165m█\033[38;2;56;91;166m║
|
|
||||||
+ \033[38;2;215;23;133m╚\033[38;2;212;24;134m═\033[38;2;209;26;134m╝\033[38;2;205;27;135m \033[38;2;202;28;136m \033[38;2;199;30;136m \033[38;2;196;31;137m \033[38;2;193;33;138m \033[38;2;190;34;138m╚\033[38;2;186;35;139m═\033[38;2;183;37;140m═\033[38;2;180;38;140m═\033[38;2;177;39;141m═\033[38;2;174;41;142m═\033[38;2;170;42;142m═\033[38;2;167;43;143m╝ \033[38;2;164;45;144m╚\033[38;2;161;46;144m═\033[38;2;158;47;145m╝\033[38;2;155;49;146m \033[38;2;151;50;146m \033[38;2;148;52;147m╚\033[38;2;145;53;148m═\033[38;2;142;54;148m╝ \033[38;2;139;56;149m╚\033[38;2;135;57;149m═\033[38;2;132;58;150m═\033[38;2;129;60;151m═\033[38;2;126;61;151m═\033[38;2;123;62;152m═\033[38;2;120;64;153m═\033[38;2;116;65;153m╝ \033[38;2;113;67;154m╚\033[38;2;110;68;155m═\033[38;2;107;69;155m╝\033[38;2;104;71;156m \033[38;2;101;72;157m \033[38;2;97;73;157m \033[38;2;94;75;158m \033[38;2;91;76;159m \033[38;2;88;77;159m╚\033[38;2;85;79;160m═\033[38;2;81;80;161m╝ \033[38;2;78;81;161m╚\033[38;2;75;83;162m═\033[38;2;72;84;163m╝\033[38;2;69;86;163m \033[38;2;66;87;164m \033[38;2;62;88;165m╚\033[38;2;59;90;165m═\033[38;2;56;91;166m╝\033[0m
|
|
||||||
+ """;
|
|
||||||
+
|
|
||||||
+ // Support URLs
|
|
||||||
+ public static final String DOWNLOAD_PAGE = "https://plazmamc.org/downloads";
|
|
||||||
+ public static final String CONFIG_REFERENCE = "https://docs.plazmamc.org/plazma/administration/reference/configurations";
|
|
||||||
+ public static final String START_GUIDE = "https://docs.plazmamc.org/plazma/administration/getting-started";
|
|
||||||
+ public static final String USAGE_GUIDE = "https://docs.plazmamc.org/plazma/administration/getting-started/next-step";
|
|
||||||
+ public static final String SUPPORT_PAGE = "https://github.com/PlazmaMC/Plazma/issues";
|
|
||||||
+
|
|
||||||
+ // DO NOT MODIFY BELOW
|
|
||||||
+ public static final String BRAND_LCASE = BRAND_NAME.toLowerCase();
|
|
||||||
+ public static final String BRAND_UCASE = BRAND_NAME.toUpperCase();
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
|
||||||
index 3099c21ee..a337e2c95 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
|
||||||
@@ -30,10 +30,6 @@ public record ServerBuildInfoImpl(
|
|
||||||
private static final String ATTRIBUTE_GIT_BRANCH = "Git-Branch";
|
|
||||||
private static final String ATTRIBUTE_GIT_COMMIT = "Git-Commit";
|
|
||||||
|
|
||||||
- private static final String BRAND_PAPER_NAME = "Paper";
|
|
||||||
- private static final String BRAND_PUFFERFISH_NAME = "Pufferfish"; // Purpur
|
|
||||||
- private static final String BRAND_PURPUR_NAME = "Purpur"; // Purpur
|
|
||||||
-
|
|
||||||
private static final String BUILD_DEV = "DEV";
|
|
||||||
|
|
||||||
public ServerBuildInfoImpl() {
|
|
||||||
@@ -44,9 +40,9 @@ public record ServerBuildInfoImpl(
|
|
||||||
this(
|
|
||||||
getManifestAttribute(manifest, ATTRIBUTE_BRAND_ID)
|
|
||||||
.map(Key::key)
|
|
||||||
- .orElse(BRAND_PURPUR_ID), // Purpur
|
|
||||||
+ .orElse(BRAND_ID), // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
getManifestAttribute(manifest, ATTRIBUTE_BRAND_NAME)
|
|
||||||
- .orElse(BRAND_PURPUR_NAME), // Purpur
|
|
||||||
+ .orElse(ServerBrandConstants.BRAND_NAME), // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
SharedConstants.getCurrentVersion().getId(),
|
|
||||||
SharedConstants.getCurrentVersion().getName(),
|
|
||||||
getManifestAttribute(manifest, ATTRIBUTE_BUILD_NUMBER)
|
|
||||||
@@ -63,7 +59,7 @@ public record ServerBuildInfoImpl(
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBrandCompatible(final @NotNull Key brandId) {
|
|
||||||
- return brandId.equals(this.brandId) || brandId.equals(BRAND_PAPER_ID) || brandId.equals(BRAND_PUFFERFISH_ID); // Purpur
|
|
||||||
+ return brandId.equals(this.brandId) || SUPPORTED_BRANDS.contains(brandId); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
||||||
index 87e5f614b..17e52f4b6 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
||||||
@@ -113,9 +113,7 @@ public abstract class Configurations<G, W> {
|
|
||||||
try {
|
|
||||||
loader.save(node);
|
|
||||||
} catch (ConfigurateException ex) {
|
|
||||||
- if (ex.getCause() instanceof AccessDeniedException) {
|
|
||||||
- LOGGER.warn("Could not save {}: Paper could not persist the full set of configuration settings in the configuration file. Any setting missing from the configuration file will be set with its default value in memory. Admins should make sure to review the configuration documentation at https://docs.papermc.io/paper/configuration for more details.", filename, ex);
|
|
||||||
- } else throw ex;
|
|
||||||
+ if (ex.getCause() instanceof AccessDeniedException) LOGGER.warn("Could not save {}: {} could not persist the full set of configuration settings in the configuration file. Any setting missing from the configuration file will be set with its default value in memory. Admins should make sure to review the configuration documentation at {} for more details.", filename, io.papermc.paper.ServerBuildInfo.buildInfo().brandName(), io.papermc.paper.ServerBrandConstants.CONFIG_REFERENCE, ex) else throw ex; // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java
|
|
||||||
index 710477ae2..318780240 100644
|
|
||||||
--- a/src/main/java/net/minecraft/CrashReport.java
|
|
||||||
+++ b/src/main/java/net/minecraft/CrashReport.java
|
|
||||||
@@ -32,13 +32,13 @@ public class CrashReport {
|
|
||||||
private boolean trackingStackTrace = true;
|
|
||||||
private StackTraceElement[] uncategorizedStackTrace = new StackTraceElement[0];
|
|
||||||
private final SystemReport systemReport = new SystemReport();
|
|
||||||
- private List<String> extraInfo = List.of("", "DO NOT REPORT THIS TO PAPER! REPORT TO PURPUR INSTEAD!", ""); // Purpur - Rebrand
|
|
||||||
+ private List<String> extraInfo = List.of("", "DO NOT REPORT THIS TO PAPER OR PURPUR! REPORT TO " + io.papermc.paper.ServerBrandConstants.BRAND_UCASE + " INSTEAD!", ""); // Purpur - Rebrand // Plazma - Fork-friendly Rebranding
|
|
||||||
|
|
||||||
public CrashReport(String message, Throwable cause) {
|
|
||||||
io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(cause); // Paper
|
|
||||||
this.title = message;
|
|
||||||
this.exception = cause;
|
|
||||||
- this.systemReport.setDetail("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit
|
|
||||||
+ this.systemReport.setDetail(io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
|
||||||
index aad2cdf4c..ac2f6591d 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/Main.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
|
||||||
@@ -108,6 +108,11 @@ public class Main {
|
|
||||||
*/ // CraftBukkit end
|
|
||||||
|
|
||||||
try {
|
|
||||||
+ // Plazma start - Fork-friendly Rebranding
|
|
||||||
+ //noinspection ConstantValue
|
|
||||||
+ if (io.papermc.paper.ServerBrandConstants.ASCII_LOGO != null)
|
|
||||||
+ System.out.println(io.papermc.paper.ServerBrandConstants.ASCII_LOGO);
|
|
||||||
+ // Plazma end - Fork-friendly Rebranding
|
|
||||||
|
|
||||||
Path path = (Path) optionset.valueOf("pidFile"); // CraftBukkit
|
|
||||||
|
|
||||||
@@ -179,7 +184,7 @@ public class Main {
|
|
||||||
if (awtException != null) {
|
|
||||||
Main.LOGGER.error("You are using a headless JRE distribution.");
|
|
||||||
Main.LOGGER.error("This distribution is missing certain graphic libraries that the Minecraft server needs to function.");
|
|
||||||
- Main.LOGGER.error("For instructions on how to install the non-headless JRE, see https://docs.papermc.io/misc/java-install");
|
|
||||||
+ Main.LOGGER.error("For instructions on how to install the non-headless JRE, see {}", io.papermc.paper.ServerBrandConstants.START_GUIDE); // Plazma - Fork-friendly Rebranding
|
|
||||||
Main.LOGGER.error("");
|
|
||||||
Main.LOGGER.error(awtException);
|
|
||||||
return;
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
index d78cb68c3..e36b99645 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
@@ -1259,7 +1259,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
LOGGER.info("*************************************************************************************");
|
|
||||||
LOGGER.info("This is the first time you're starting this server.");
|
|
||||||
LOGGER.info("It's recommended you read our 'Getting Started' documentation for guidance.");
|
|
||||||
- LOGGER.info("View this and more helpful information here: https://docs.papermc.io/paper/next-steps");
|
|
||||||
+ LOGGER.info("View this and more helpful information here: {}", io.papermc.paper.ServerBrandConstants.START_GUIDE); // Plazma - Fork-friendly Rebranding
|
|
||||||
LOGGER.info("*************************************************************************************");
|
|
||||||
}
|
|
||||||
// Paper end - Add onboarding message for initial server start
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
index 6e6f4dffc..68780b0ae 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
@@ -801,7 +801,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
||||||
org.bukkit.plugin.Plugin[] plugins = this.server.getPluginManager().getPlugins();
|
|
||||||
|
|
||||||
result.append(this.server.getName());
|
|
||||||
- result.append(" on Bukkit ");
|
|
||||||
+ result.append(" on ").append(io.papermc.paper.ServerBuildInfo.buildInfo().brandName()).append(" "); // Plazma - Fork-friendly Rebranding
|
|
||||||
result.append(this.server.getBukkitVersion());
|
|
||||||
|
|
||||||
if (plugins.length > 0 && this.server.getQueryPlugins()) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
||||||
index 9ebe1f179..5971f99c0 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
||||||
@@ -56,12 +56,12 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
|
||||||
public final boolean onlineMode = this.get("online-mode", true);
|
|
||||||
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
|
|
||||||
public final String serverIp = this.get("server-ip", "");
|
|
||||||
- public final String serverName = this.get("server-name", "Unknown Server"); // Purpur
|
|
||||||
+ public final String serverName = this.get("server-name", "A " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " Server"); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
public final boolean spawnAnimals = this.get("spawn-animals", true);
|
|
||||||
public final boolean spawnNpcs = this.get("spawn-npcs", true);
|
|
||||||
public final boolean pvp = this.get("pvp", true);
|
|
||||||
public final boolean allowFlight = this.get("allow-flight", false);
|
|
||||||
- public final String motd = this.get("motd", "A Minecraft Server");
|
|
||||||
+ public final String motd = this.get("motd", "A " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " Server"); // Plazma - Fork-friendly Rebranding
|
|
||||||
public final String bugReportLink = this.get("bug-report-link", "");
|
|
||||||
public final boolean forceGameMode = this.get("force-gamemode", false);
|
|
||||||
public final boolean enforceWhitelist = this.get("enforce-whitelist", false);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
|
|
||||||
index 8f74c2ec5252b6265549589310d742337c91cb2c..f8e8966fe8909f209969637e7ed708e689c41f1d 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
|
|
||||||
@@ -56,7 +56,7 @@ public class MinecraftServerGui extends JComponent {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
- final JFrame jframe = new JFrame("Purpur Minecraft server"); // Purpur
|
|
||||||
+ final JFrame jframe = new JFrame(io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " Minecraft server"); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
final MinecraftServerGui servergui = new MinecraftServerGui(server);
|
|
||||||
|
|
||||||
jframe.setDefaultCloseOperation(2);
|
|
||||||
@@ -64,7 +64,7 @@ public class MinecraftServerGui extends JComponent {
|
|
||||||
jframe.pack();
|
|
||||||
jframe.setLocationRelativeTo((Component) null);
|
|
||||||
jframe.setVisible(true);
|
|
||||||
- jframe.setName("Purpur Minecraft server"); // Paper - Improve ServerGUI // Purpur
|
|
||||||
+ jframe.setName(io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " Minecraft server"); // Paper - Improve ServerGUI // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
|
|
||||||
// Paper start - Improve ServerGUI
|
|
||||||
try {
|
|
||||||
@@ -76,7 +76,7 @@ public class MinecraftServerGui extends JComponent {
|
|
||||||
jframe.addWindowListener(new WindowAdapter() {
|
|
||||||
public void windowClosing(WindowEvent windowevent) {
|
|
||||||
if (!servergui.isClosing.getAndSet(true)) {
|
|
||||||
- jframe.setTitle("Purpur Minecraft server - shutting down!"); // Purpur
|
|
||||||
+ jframe.setTitle(io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " Minecraft server - shutting down!"); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
server.halt(true);
|
|
||||||
servergui.runFinalizers();
|
|
||||||
}
|
|
||||||
@@ -123,7 +123,7 @@ public class MinecraftServerGui extends JComponent {
|
|
||||||
|
|
||||||
// Paper start - Add onboarding message for initial server start
|
|
||||||
private JComponent buildOnboardingPanel() {
|
|
||||||
- String onboardingLink = "https://docs.papermc.io/paper/next-steps";
|
|
||||||
+ String onboardingLink = io.papermc.paper.ServerBrandConstants.USAGE_GUIDE; // Plazma - Fork-friendly Rebranding
|
|
||||||
JPanel jPanel = new JPanel();
|
|
||||||
|
|
||||||
javax.swing.JLabel jLabel = new javax.swing.JLabel("If you need help setting up your server you can visit:");
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
||||||
index 4a96d914f..0e786cf02 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
||||||
@@ -89,7 +89,7 @@ public class DamageSource {
|
|
||||||
|
|
||||||
public DamageSource customEventDamager(Entity entity) {
|
|
||||||
if (this.directEntity != null) {
|
|
||||||
- throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper)");
|
|
||||||
+ throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + ")"); // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
DamageSource damageSource = this.cloneInstance();
|
|
||||||
damageSource.customEventDamager = entity;
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
|
||||||
index 4c178b234..28b1374e2 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
|
||||||
@@ -177,7 +177,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
|
||||||
|
|
||||||
// Paper start
|
|
||||||
private static void printOversizedLog(String msg, Path file, int x, int z) {
|
|
||||||
- org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PURPUR - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); // Purpur
|
|
||||||
+ org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException {
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
||||||
index 068aa459b..8d67bf7aa 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
||||||
@@ -143,7 +143,7 @@ public class Main {
|
|
||||||
|
|
||||||
this.acceptsAll(Main.asList("noconsole"), "Disables the console");
|
|
||||||
|
|
||||||
- this.acceptsAll(Main.asList("v", "version"), "Show the CraftBukkit Version");
|
|
||||||
+ this.acceptsAll(Main.asList("v", "version"), "Show the " + io.papermc.paper.ServerBrandConstants.BRAND_NAME + " Version"); // Plazma - Fork-friendly Rebranding
|
|
||||||
|
|
||||||
this.acceptsAll(Main.asList("demo"), "Demo mode");
|
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ public class Main {
|
|
||||||
acceptsAll(asList("server-name"), "Name of the server")
|
|
||||||
.withRequiredArg()
|
|
||||||
.ofType(String.class)
|
|
||||||
- .defaultsTo("Unknown Server")
|
|
||||||
+ .defaultsTo("A " + io.papermc.paper.ServerBrandConstants.BRAND_NAME + " Server") // Plazma - Fork-friendly Rebranding
|
|
||||||
.describedAs("Name");
|
|
||||||
// Paper end
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
||||||
index 48999a860..4004699d0 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
||||||
@@ -492,7 +492,7 @@ public class CraftScheduler implements BukkitScheduler {
|
|
||||||
this.parsePending();
|
|
||||||
} else {
|
|
||||||
// this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper
|
|
||||||
- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Purpur"); // Paper // Purpur
|
|
||||||
+ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName()); // Paper // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
// We don't need to parse pending
|
|
||||||
// (async tasks must live with race-conditions if they attempt to cancel between these few lines of code)
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
|
||||||
index 99597258e8e88cd9e2c901c4ac3ff7faeeabee2b..e8f7250f366bf9407ffd6d2ce53fd68a3753f97c 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
|
||||||
@@ -11,7 +11,7 @@ public final class Versioning {
|
|
||||||
public static String getBukkitVersion() {
|
|
||||||
String result = "Unknown-Version";
|
|
||||||
|
|
||||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.purpurmc.purpur/purpur-api/pom.properties"); // Pufferfish // Purpur
|
|
||||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream(io.papermc.paper.ServerBrandConstants.RESOURCE_PATH); // Pufferfish // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
Properties properties = new Properties();
|
|
||||||
|
|
||||||
if (stream != null) {
|
|
||||||
@@ -20,7 +20,7 @@ public final class Versioning {
|
|
||||||
|
|
||||||
result = properties.getProperty("version");
|
|
||||||
} catch (IOException ex) {
|
|
||||||
- Logger.getLogger(Versioning.class.getName()).log(Level.SEVERE, "Could not get Bukkit version!", ex);
|
|
||||||
+ Logger.getLogger(Versioning.class.getName()).log(Level.SEVERE, "Could not get " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " version!", ex); // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
|
||||||
index f51cc3de3..4910b3fb5 100644
|
|
||||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
|
||||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
|
||||||
@@ -155,14 +155,14 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
|
|
||||||
if (isLongTimeout) {
|
|
||||||
// Paper end
|
|
||||||
log.log( Level.SEVERE, "------------------------------" );
|
|
||||||
- log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Purpur bug." ); // Paper // Purpur
|
|
||||||
+ log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " bug." ); // Paper // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" );
|
|
||||||
log.log( Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring" );
|
|
||||||
log.log( Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once" );
|
|
||||||
log.log( Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes" );
|
|
||||||
- log.log( Level.SEVERE, "If you are unsure or still think this is a Purpur bug, please report this to https://github.com/PurpurMC/Purpur/issues" ); // Purpur
|
|
||||||
+ log.log( Level.SEVERE, "If you are unsure or still think this is a " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " bug, please report this to " + io.papermc.paper.ServerBrandConstants.SUPPORT_PAGE ); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" );
|
|
||||||
- log.log( Level.SEVERE, "Purpur version: " + Bukkit.getServer().getVersion() ); // Purpur
|
|
||||||
+ log.log( Level.SEVERE, io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " version: " + Bukkit.getServer().getVersion() ); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
//
|
|
||||||
if ( net.minecraft.world.level.Level.lastPhysicsProblem != null )
|
|
||||||
{
|
|
||||||
@@ -184,12 +184,12 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
|
|
||||||
// Paper end
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PURPUR - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Purpur
|
|
||||||
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO " + io.papermc.paper.ServerBrandConstants.BRAND_UCASE + " - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
log.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump");
|
|
||||||
}
|
|
||||||
// Paper end - Different message for short timeout
|
|
||||||
log.log( Level.SEVERE, "------------------------------" );
|
|
||||||
- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Purpur!):" ); // Paper // Purpur
|
|
||||||
+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + "!):" ); // Paper // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(MinecraftServer.getServer(), isLongTimeout); // Paper - rewrite chunk system
|
|
||||||
this.dumpTickingInfo(); // Paper - log detailed tick information
|
|
||||||
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
|
|
||||||
@@ -205,7 +205,7 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
|
|
||||||
WatchdogThread.dumpThread( thread, log );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PURPUR - THIS IS NOT A BUG OR A CRASH ---"); // Purpur
|
|
||||||
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO " + io.papermc.paper.ServerBuildInfo.buildInfo().brandName() + " - THIS IS NOT A BUG OR A CRASH ---"); // Purpur // Plazma - Fork-friendly Rebranding
|
|
||||||
}
|
|
||||||
|
|
||||||
log.log( Level.SEVERE, "------------------------------" );
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,105 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 5 Nov 2023 10:47:05 +0900
|
|
||||||
Subject: [PATCH] Setup basic configuration sections
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
index d8006ae086c18a4ef43906d516eba0d5fd397f5f..57d29f8f3bc89529db9ee8f6dc3fffdbd4a03ceb 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
@@ -3,6 +3,7 @@ package org.plazmamc.plazma.configurations;
|
|
||||||
import io.papermc.paper.configuration.Configuration;
|
|
||||||
import io.papermc.paper.configuration.ConfigurationPart;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.spongepowered.configurate.objectmapping.meta.PostProcess;
|
|
||||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
|
||||||
|
|
||||||
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "InnerClassMayBeStatic"})
|
|
||||||
@@ -23,4 +24,43 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|
||||||
@Setting(Configuration.VERSION_FIELD)
|
|
||||||
int version = VERSION;
|
|
||||||
|
|
||||||
+ public Player player;
|
|
||||||
+ public class Player extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Setting("world-generation")
|
|
||||||
+ public WorldGeneration worldgen;
|
|
||||||
+ public class WorldGeneration extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public Entity entity;
|
|
||||||
+ public class Entity extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ @PostProcess
|
|
||||||
+ public void post() {
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public World world;
|
|
||||||
+ public class World extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ @PostProcess
|
|
||||||
+ public void post() {
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public Miscellaneous misc;
|
|
||||||
+ public class Miscellaneous extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
index f2d3d51cb4b8fc7a5fd6db1a63289fff6d32a1ea..8dce68cf7769fcd5ea03be32621ccb6bab174697 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
@@ -19,4 +19,38 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
||||||
@Setting(Configuration.VERSION_FIELD)
|
|
||||||
int version = VERSION;
|
|
||||||
|
|
||||||
+ public Miscellaneous misc;
|
|
||||||
+ public class Miscellaneous extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public Entity entity;
|
|
||||||
+ public class Entity extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+ public Phantom phantom;
|
|
||||||
+ public class Phantom extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public Structure structure;
|
|
||||||
+ public class Structure extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+ public NetherPortal netherPortal;
|
|
||||||
+ public class NetherPortal extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public Block block;
|
|
||||||
+ public class Block extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
}
|
|
||||||
@@ -1,900 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Thu, 25 Jan 2024 17:13:09 +0900
|
|
||||||
Subject: [PATCH] Port SparklyPaper patches
|
|
||||||
|
|
||||||
SparklyPower
|
|
||||||
Copyright (C) 2024 SparklyPower
|
|
||||||
|
|
||||||
Based on commit: 29212936a832106c4d68e2a2017acbea2fdd3cc4
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/command/MSPTCommand.java b/src/main/java/io/papermc/paper/command/MSPTCommand.java
|
|
||||||
index 8b5293b0c696ef21d0101493ffa41b60bf0bc86b..03be23690a94a14d7343526acad67ccf53b85c70 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/command/MSPTCommand.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/command/MSPTCommand.java
|
|
||||||
@@ -78,6 +78,47 @@ public final class MSPTCommand extends Command {
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
+
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
+ sender.sendMessage(text());
|
|
||||||
+ sender.sendMessage(text().content("World tick times ").color(GOLD)
|
|
||||||
+ .append(text().color(YELLOW)
|
|
||||||
+ .append(
|
|
||||||
+ text("("),
|
|
||||||
+ text("avg", GRAY),
|
|
||||||
+ text("/"),
|
|
||||||
+ text("min", GRAY),
|
|
||||||
+ text("/"),
|
|
||||||
+ text("max", GRAY),
|
|
||||||
+ text(")")
|
|
||||||
+ )
|
|
||||||
+ ).append(
|
|
||||||
+ text(" from last 5s"),
|
|
||||||
+ text(",", GRAY),
|
|
||||||
+ text(" 10s"),
|
|
||||||
+ text(",", GRAY),
|
|
||||||
+ text(" 1m"),
|
|
||||||
+ text(":", YELLOW)
|
|
||||||
+ )
|
|
||||||
+ );
|
|
||||||
+ for (net.minecraft.server.level.ServerLevel level: server.getAllLevels()) {
|
|
||||||
+ List<Component> worldTimes = new ArrayList<>();
|
|
||||||
+ worldTimes.addAll(eval(level.tickTimes5s.getTimes()));
|
|
||||||
+ worldTimes.addAll(eval(level.tickTimes10s.getTimes()));
|
|
||||||
+ worldTimes.addAll(eval(level.tickTimes60s.getTimes()));
|
|
||||||
+
|
|
||||||
+ sender.sendMessage(text().content("◴ " + level.getWorld().getName() + ": ").color(GOLD)
|
|
||||||
+ .append(text().color(GRAY)
|
|
||||||
+ .append(
|
|
||||||
+ worldTimes.get(0), SLASH, worldTimes.get(1), SLASH, worldTimes.get(2), text(", ", YELLOW),
|
|
||||||
+ worldTimes.get(3), SLASH, worldTimes.get(4), SLASH, worldTimes.get(5), text(", ", YELLOW),
|
|
||||||
+ worldTimes.get(6), SLASH, worldTimes.get(7), SLASH, worldTimes.get(8)
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ );
|
|
||||||
+ }
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
+
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/EntityScheduler.java b/src/main/java/io/papermc/paper/threadedregions/EntityScheduler.java
|
|
||||||
index c03608fec96b51e1867f43d8f42e5aefb1520e46..93180066224345c0332fb33744f84204f15bba29 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/threadedregions/EntityScheduler.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/threadedregions/EntityScheduler.java
|
|
||||||
@@ -41,6 +41,7 @@ public final class EntityScheduler {
|
|
||||||
|
|
||||||
private long tickCount = 0L;
|
|
||||||
private static final long RETIRED_TICK_COUNT = -1L;
|
|
||||||
+ private static final net.minecraft.server.MinecraftServer SERVER = net.minecraft.server.MinecraftServer.getServer(); // Plazma - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
private final Object stateLock = new Object();
|
|
||||||
private final Long2ObjectOpenHashMap<List<ScheduledTask>> oneTimeDelayed = new Long2ObjectOpenHashMap<>();
|
|
||||||
|
|
||||||
@@ -61,15 +62,15 @@ public final class EntityScheduler {
|
|
||||||
* @throws IllegalStateException If the scheduler is already retired.
|
|
||||||
*/
|
|
||||||
public void retire() {
|
|
||||||
+ final Entity thisEntity = this.entity.getHandleRaw(); // Plazma - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
synchronized (this.stateLock) {
|
|
||||||
if (this.tickCount == RETIRED_TICK_COUNT) {
|
|
||||||
throw new IllegalStateException("Already retired");
|
|
||||||
}
|
|
||||||
this.tickCount = RETIRED_TICK_COUNT;
|
|
||||||
+ SERVER.entitiesWithScheduledTasks.remove(thisEntity); // Plazma - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
}
|
|
||||||
|
|
||||||
- final Entity thisEntity = this.entity.getHandleRaw();
|
|
||||||
-
|
|
||||||
// correctly handle and order retiring while running executeTick
|
|
||||||
for (int i = 0, len = this.currentlyExecuting.size(); i < len; ++i) {
|
|
||||||
final ScheduledTask task = this.currentlyExecuting.pollFirst();
|
|
||||||
@@ -124,6 +125,7 @@ public final class EntityScheduler {
|
|
||||||
if (this.tickCount == RETIRED_TICK_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
+ SERVER.entitiesWithScheduledTasks.add(this.entity.getHandleRaw()); // Plazma - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
this.oneTimeDelayed.computeIfAbsent(this.tickCount + Math.max(1L, delay), (final long keyInMap) -> {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}).add(task);
|
|
||||||
@@ -143,6 +145,12 @@ public final class EntityScheduler {
|
|
||||||
TickThread.ensureTickThread(thisEntity, "May not tick entity scheduler asynchronously");
|
|
||||||
final List<ScheduledTask> toRun;
|
|
||||||
synchronized (this.stateLock) {
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
+ if (this.currentlyExecuting.isEmpty() && this.oneTimeDelayed.isEmpty()) {
|
|
||||||
+ SERVER.entitiesWithScheduledTasks.remove(thisEntity);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
if (this.tickCount == RETIRED_TICK_COUNT) {
|
|
||||||
throw new IllegalStateException("Ticking retired scheduler");
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
index ccfeda1ba3f89112eccf29f382b5526934db1d91..c63910d9215875e91968c509932b9f5393bb6457 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
@@ -327,6 +327,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
public volatile boolean abnormalExit = false; // Paper
|
|
||||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
|
||||||
public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("MobSpawning"); // Pufferfish - optimize mob spawning
|
|
||||||
+ public final Set<Entity> entitiesWithScheduledTasks = java.util.concurrent.ConcurrentHashMap.newKeySet(); // Plazma - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
|
|
||||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
|
||||||
AtomicReference<S> atomicreference = new AtomicReference();
|
|
||||||
@@ -1773,17 +1774,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
//MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Paper // Purpur
|
|
||||||
// Paper start - Folia scheduler API
|
|
||||||
((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).tick();
|
|
||||||
- getAllLevels().forEach(level -> {
|
|
||||||
- for (final Entity entity : level.moonrise$getEntityLookup().getAllCopy()) { // Paper - rewrite chunk system
|
|
||||||
- if (entity.isRemoved()) {
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
- final org.bukkit.craftbukkit.entity.CraftEntity bukkit = entity.getBukkitEntityRaw();
|
|
||||||
- if (bukkit != null) {
|
|
||||||
- bukkit.taskScheduler.executeTick();
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- });
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
+ for (final Entity entity : entitiesWithScheduledTasks) {
|
|
||||||
+ if (entity.isRemoved() || entity.getBukkitEntityRaw() == null) continue;
|
|
||||||
+ bukkit.taskScheduler.executeTick();
|
|
||||||
+ }
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
|
||||||
// Paper end - Folia scheduler API
|
|
||||||
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.CALLBACK_MANAGER.handleQueue(this.tickCount); // Paper
|
|
||||||
//this.profiler.push("commandFunctions"); // Purpur
|
|
||||||
@@ -1849,8 +1845,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
//this.profiler.push("tick"); // Purpur
|
|
||||||
|
|
||||||
try {
|
|
||||||
- //worldserver.timings.doTick.startTiming(); // Spigot // Purpur
|
|
||||||
- worldserver.tick(shouldKeepTicking);
|
|
||||||
+ //worldserver.timings.doTick.startTiming(); // Spigot // Purpur// Plazma start - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
+ long before = Util.getNanos();
|
|
||||||
+ worldserver.tick(shouldKeepTicking); // diff on changes
|
|
||||||
+ long after = Util.getNanos() - before;
|
|
||||||
+
|
|
||||||
+ worldserver.tickTimes5s.add(this.tickCount, after);
|
|
||||||
+ worldserver.tickTimes10s.add(this.tickCount, after);
|
|
||||||
+ worldserver.tickTimes60s.add(this.tickCount, after);
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
//worldserver.timings.doTick.stopTiming(); // Spigot // Purpur
|
|
||||||
} catch (Throwable throwable) {
|
|
||||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
index 1bc42bcb5ecbf800684484530260192cc0ed0c5f..f6afc085b903fe0a71109792593da21b665a5300 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
@@ -237,6 +237,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
||||||
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
|
||||||
this.plazmaConfigurations.initializeGlobalConfiguration(this.registryAccess()); // Plazma - Configurable Plazma
|
|
||||||
this.plazmaConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); // Plazma - Configurable Plazma
|
|
||||||
+ net.sparklypower.sparklypaper.HalloweenManager.startSyncEpochTask(); // Plazma - Port SparklyPaper patches; Optimize Spooky Season
|
|
||||||
// Paper end - initialize global and world-defaults configuration
|
|
||||||
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
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
||||||
index 1883abec14e05f8eb2e865446b4d81091b1aa5e0..adfc891ae8868bb562910ad169c116e5d30348c7 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
||||||
@@ -1262,7 +1262,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
||||||
// Paper end - Configurable entity tracking range by Y
|
|
||||||
|
|
||||||
// CraftBukkit start - respect vanish API
|
|
||||||
- if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
|
|
||||||
+ if (flag && !player.getBukkitEntity().chunkMapCanSee(this.entity.getBukkitEntity())) { // Paper - only consider hits // Plazma - Port SparklyPaper patches; Optimize canSee check
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
||||||
index dfd09004063a8d8d93357633c8d23b6acff67b73..a0ddb5eb48448f869855d2b613c667b2d42066f3 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
||||||
@@ -78,6 +78,7 @@ public class ServerEntity {
|
|
||||||
private List<SynchedEntityData.DataValue<?>> trackedDataValues;
|
|
||||||
// CraftBukkit start
|
|
||||||
public final Set<ServerPlayerConnection> trackedPlayers; // Purpur - private -> public
|
|
||||||
+ public static boolean skipSqrWhenNoDeltaChanges = false; // Plazma - SparklyPaper port; Skip distanceToSqr if the delta movement hasn't changed
|
|
||||||
|
|
||||||
public ServerEntity(ServerLevel worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<ServerPlayerConnection> trackedPlayers) {
|
|
||||||
this.trackedPlayers = trackedPlayers;
|
|
||||||
@@ -218,20 +219,21 @@ public class ServerEntity {
|
|
||||||
|
|
||||||
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
|
||||||
Vec3 vec3d1 = this.entity.getDeltaMovement();
|
|
||||||
- double d0 = vec3d1.distanceToSqr(this.lastSentMovement);
|
|
||||||
-
|
|
||||||
- if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) {
|
|
||||||
- this.lastSentMovement = vec3d1;
|
|
||||||
- Entity entity1 = this.entity;
|
|
||||||
-
|
|
||||||
- if (entity1 instanceof AbstractHurtingProjectile) {
|
|
||||||
- AbstractHurtingProjectile entityfireball = (AbstractHurtingProjectile) entity1;
|
|
||||||
-
|
|
||||||
- this.broadcast.accept(new ClientboundBundlePacket(List.of(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement), new ClientboundProjectilePowerPacket(entityfireball.getId(), entityfireball.accelerationPower))));
|
|
||||||
- } else {
|
|
||||||
- this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+ // Plazma start - SparklyPaper port; Skip distanceToSqr if the delta movement hasn't changed
|
|
||||||
+ if (!skipSqrWhenNoDeltaChanges && vec3d1 != this.ap) {
|
|
||||||
+ double d0 = vec3d1.distanceToSqr(this.lastSentMovement);
|
|
||||||
+ if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) {
|
|
||||||
+ this.lastSentMovement = vec3d1;
|
|
||||||
+ Entity entity1 = this.entity;
|
|
||||||
+ if (entity1 instanceof AbstractHurtingProjectile) {
|
|
||||||
+ AbstractHurtingProjectile entityfireball = (AbstractHurtingProjectile) entity1;
|
|
||||||
+ this.broadcast.accept(new ClientboundBundlePacket(List.of(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement), new ClientboundProjectilePowerPacket(entityfireball.getId(), entityfireball.accelerationPower))));
|
|
||||||
+ } else {
|
|
||||||
+ this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
|
||||||
+ }
|
|
||||||
+ } // diff on changes
|
|
||||||
+ } // diff on changes
|
|
||||||
+ // Plazma end - SparklyPaper port; Skip distanceToSqr if the delta movement hasn't changed
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packet1 != null) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
index dfcd3989ffbd4aa5dc9368a34b95c1c2748c23a2..f5f944899d860d8363db43d430f3daab96e0d774 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
@@ -233,6 +233,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
|
||||||
private final alternate.current.wire.WireHandler wireHandler = new alternate.current.wire.WireHandler(this); // Paper - optimize redstone (Alternate Current)
|
|
||||||
public boolean hasRidableMoveEvent = false; // Purpur
|
|
||||||
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
+ public final MinecraftServer.TickTimes tickTimes5s = new MinecraftServer.TickTimes(100);
|
|
||||||
+ public final MinecraftServer.TickTimes tickTimes10s = new MinecraftServer.TickTimes(200);
|
|
||||||
+ public final MinecraftServer.TickTimes tickTimes60s = new MinecraftServer.TickTimes(1200);
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
+
|
|
||||||
public LevelChunk getChunkIfLoaded(int x, int z) {
|
|
||||||
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
|
||||||
index fb7342f7a5008a283c3400c6313c637de8210dfa..8b068f6b4c52cdba60a7fbe21bc1f7a86891800a 100644
|
|
||||||
--- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
|
||||||
+++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
|
||||||
@@ -90,12 +90,14 @@ public class ServerStatsCounter extends StatsCounter {
|
|
||||||
this.dirty.add(stat);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* // Plazma - Port SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
|
||||||
private Set<Stat<?>> getDirty() {
|
|
||||||
Set<Stat<?>> set = Sets.newHashSet(this.dirty);
|
|
||||||
|
|
||||||
this.dirty.clear();
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
+ */ // Plazma - Port SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
|
||||||
|
|
||||||
public void parseLocal(DataFixer dataFixer, String json) {
|
|
||||||
try {
|
|
||||||
@@ -243,7 +245,7 @@ public class ServerStatsCounter extends StatsCounter {
|
|
||||||
|
|
||||||
public void sendStats(ServerPlayer player) {
|
|
||||||
Object2IntMap<Stat<?>> object2intmap = new Object2IntOpenHashMap();
|
|
||||||
- Iterator iterator = this.getDirty().iterator();
|
|
||||||
+ Iterator<Stat<?>> iterator = this.dirty.iterator(); // Plazma - SparklyPaper port; Skip dirty stats copy when requesting player stats
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Stat<?> statistic = (Stat) iterator.next();
|
|
||||||
@@ -251,6 +253,7 @@ public class ServerStatsCounter extends StatsCounter {
|
|
||||||
object2intmap.put(statistic, this.getValue(statistic));
|
|
||||||
}
|
|
||||||
|
|
||||||
+ this.dirty.clear(); // Plazma - SparklyPaper port; Skip dirty stats copy when requesting player stats
|
|
||||||
player.connection.send(new ClientboundAwardStatsPacket(object2intmap));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 36e5a6462675ceb3cef236c451321b1656d9fcc0..bdc2391aed4fedc2e15a0b51a6930a2d85905c90 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
|
||||||
@@ -307,7 +307,7 @@ public class Bat extends AmbientCreature {
|
|
||||||
int i = world.getMaxLocalRawBrightness(pos);
|
|
||||||
byte b0 = 4;
|
|
||||||
|
|
||||||
- if (Bat.isHalloweenSeason(world.getMinecraftWorld())) { // Purpur
|
|
||||||
+ if (isSpookySeason(world.getMinecraftWorld())) { // Purpur // Plazma - Port SparklyPaper patches; Optimize Spooky Season
|
|
||||||
b0 = 7;
|
|
||||||
} else if (random.nextBoolean()) {
|
|
||||||
return false;
|
|
||||||
@@ -321,7 +321,24 @@ public class Bat extends AmbientCreature {
|
|
||||||
private static boolean isSpookySeason = false;
|
|
||||||
private static final int ONE_HOUR = 20 * 60 * 60;
|
|
||||||
private static int lastSpookyCheck = -ONE_HOUR;
|
|
||||||
- public static boolean isHalloweenSeason(Level level) { return level.purpurConfig.forceHalloweenSeason || isHalloween(); } // Purpur
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Optimize Spooky Season
|
|
||||||
+ private static boolean isSpookySeason(Level level) {
|
|
||||||
+ if (level.purpurConfig.forceHalloweenSeason) return true;
|
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.spookyOptimize)
|
|
||||||
+ return net.sparklypower.sparklypaper.HalloweenManager.isSpookySeason()
|
|
||||||
+ || net.sparklypower.sparklypaper.HalloweenManager.isHalloween();
|
|
||||||
+ return isHalloween();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static boolean isHalloweenSeason(Level level) {
|
|
||||||
+ if (level.purpurConfig.forceHalloweenSeason) return true;
|
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.spookyOptimize)
|
|
||||||
+ return net.sparklypower.sparklypaper.HalloweenManager.isHalloween();
|
|
||||||
+ return isHalloween();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @SuppressWarnings("RedundantExplicitChronoField")
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Optimize Spooky Season
|
|
||||||
private static boolean isHalloween() {
|
|
||||||
if (net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) {
|
|
||||||
LocalDate localdate = LocalDate.now();
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
|
|
||||||
index 608390ed36710a419de1542b80340dd3fcc7299c..043f068345ca3c50209c1c3cc1feb6277a3da61a 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
|
||||||
@@ -268,11 +268,13 @@ public class MapItem extends ComplexItem {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ public static boolean skipTickWhenCraftNotPresent = false; // Plazma - SparklyPaper port; Skip map item ticking if the craft map renderer is not present
|
|
||||||
@Override
|
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
MapItemSavedData mapItemSavedData = getSavedData(stack, world);
|
|
||||||
if (mapItemSavedData != null) {
|
|
||||||
+ if (skipTickWhenCraftNotPresent && mapItemSavedData.mapView.getRenderers().stream().noneMatch(mapRenderer -> mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class)) return; // Plazma - SparklyPaper port; Skip map item ticking if the craft map renderer is not present
|
|
||||||
if (entity instanceof Player player) {
|
|
||||||
mapItemSavedData.tickCarriedBy(player, stack);
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
index 253d47418b4e9cbce74584c2461d12e17effd7bb..f3c44a2ddc52661984cc07b2ee23b3a3431a4b0a 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
@@ -1456,6 +1456,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
||||||
int tickedEntities = 0; // Paper - rewrite chunk system
|
|
||||||
|
|
||||||
int tilesThisCycle = 0;
|
|
||||||
+ int shouldTickBlocksAtLastResult = -1; // Plazma - Port SparklyPaper patches; Optimize tickingBlockEntities
|
|
||||||
+ long shouldTickBlocksAtChunkPos = 0; // Plazma - Port SparklyPaper patches; Optimize tickingBlockEntities
|
|
||||||
var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
|
|
||||||
toRemove.add(null); // Paper - Fix MC-117075
|
|
||||||
for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
|
||||||
@@ -1468,14 +1470,28 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
||||||
tilesThisCycle--;
|
|
||||||
toRemove.add(tickingblockentity); // Paper - Fix MC-117075; use removeAll
|
|
||||||
// Spigot end
|
|
||||||
- } else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) {
|
|
||||||
- tickingblockentity.tick();
|
|
||||||
- // Paper start - rewrite chunk system
|
|
||||||
- if ((++tickedEntities & 7) == 0) {
|
|
||||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)(Level)(Object)this).moonrise$midTickTasks();
|
|
||||||
- }
|
|
||||||
- // Paper end - rewrite chunk system
|
|
||||||
- }
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Optimize tickingBlockEntities
|
|
||||||
+ } else if (flag) {
|
|
||||||
+ long chunkPos = tickingblockentity.getChunkCoordinateKey();
|
|
||||||
+ boolean shouldTick;
|
|
||||||
+ if (shouldTickBlocksAtChunkPos == chunkPos && shouldTickBlocksAtLastResult != -1)
|
|
||||||
+ shouldTick = shouldTickBlocksAtLastResult == 1;
|
|
||||||
+ else {
|
|
||||||
+ shouldTick = this.shouldTickBlocksAt(chunkPos);
|
|
||||||
+ shouldTickBlocksAtLastResult = shouldTick ? 1 : 0;
|
|
||||||
+ shouldTickBlocksAtChunkPos = chunkPos;
|
|
||||||
+ } // diff on changes
|
|
||||||
+
|
|
||||||
+ if (shouldTick) {
|
|
||||||
+ tickingblockentity.tick();
|
|
||||||
+ // Paper start - execute chunk tasks during tick
|
|
||||||
+ if ((++tickedEntities & 7) == 0) {
|
|
||||||
+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)(Level)(Object)this).moonrise$midTickTasks();
|
|
||||||
+ }
|
|
||||||
+ // Paper end - execute chunk tasks during tick
|
|
||||||
+ } // diff on changes
|
|
||||||
+ } // diff on changes
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Optimize tickingBlockEntities
|
|
||||||
}
|
|
||||||
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java
|
|
||||||
index 5a190834baef60c7b61074393f8856a933902d81..366ae05a060b5b12b85521a4b8aed1907f3f044a 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/CropBlock.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java
|
|
||||||
@@ -77,35 +77,57 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
|
||||||
- if (world.getRawBrightness(pos, 0) >= 9) {
|
|
||||||
- int i = this.getAge(state);
|
|
||||||
-
|
|
||||||
- if (i < this.getMaxAge()) {
|
|
||||||
- float f = CropBlock.getGrowthSpeed(this, world, pos);
|
|
||||||
-
|
|
||||||
- // Spigot start
|
|
||||||
- int modifier;
|
|
||||||
- if (this == Blocks.BEETROOTS) {
|
|
||||||
- modifier = world.spigotConfig.beetrootModifier;
|
|
||||||
- } else if (this == Blocks.CARROTS) {
|
|
||||||
- modifier = world.spigotConfig.carrotModifier;
|
|
||||||
- } else if (this == Blocks.POTATOES) {
|
|
||||||
- modifier = world.spigotConfig.potatoModifier;
|
|
||||||
- // Paper start - Fix Spigot growth modifiers
|
|
||||||
- } else if (this == Blocks.TORCHFLOWER_CROP) {
|
|
||||||
- modifier = world.spigotConfig.torchFlowerModifier;
|
|
||||||
- // Paper end - Fix Spigot growth modifiers
|
|
||||||
- } else {
|
|
||||||
- modifier = world.spigotConfig.wheatModifier;
|
|
||||||
- }
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Optimize Farm checks
|
|
||||||
+ if (world.getRawBrightness(pos, 0) < 9) return;
|
|
||||||
+
|
|
||||||
+ int age = this.getAge(state);
|
|
||||||
+ if (age >= this.getMaxAge()) return;
|
|
||||||
+
|
|
||||||
+ final int modifier;
|
|
||||||
+ if (this == Blocks.BEETROOTS) {
|
|
||||||
+ modifier = world.spigotConfig.beetrootModifier;
|
|
||||||
+ } else if (this == Blocks.CARROTS) {
|
|
||||||
+ modifier = world.spigotConfig.carrotModifier;
|
|
||||||
+ } else if (this == Blocks.POTATOES) {
|
|
||||||
+ modifier = world.spigotConfig.potatoModifier;
|
|
||||||
+ } else if (this == Blocks.TORCHFLOWER_CROP) {
|
|
||||||
+ modifier = world.spigotConfig.torchFlowerModifier;
|
|
||||||
+ } else {
|
|
||||||
+ modifier = world.spigotConfig.wheatModifier;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- if (random.nextFloat() < (modifier / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
|
||||||
- // Spigot end
|
|
||||||
- CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(i + 1), 2); // CraftBukkit
|
|
||||||
- }
|
|
||||||
+ if (world.plazmaConfig().block.optimizeFarmCheck.enabled) {
|
|
||||||
+ BlockPos current = pos.below();
|
|
||||||
+ BlockState currentState = world.getBlockState(current);
|
|
||||||
+
|
|
||||||
+ boolean moist;
|
|
||||||
+ float growthSpeed;
|
|
||||||
+ if (currentState.is(Blocks.FARMLAND) && currentState.getValue(FarmBlock.MOISTURE) > 0) {
|
|
||||||
+ moist = true;
|
|
||||||
+ growthSpeed = world.plazmaConfig().block.optimizeFarmCheck.growthSpeed.moist;
|
|
||||||
+ } else {
|
|
||||||
+ moist = false;
|
|
||||||
+ growthSpeed = world.plazmaConfig().block.optimizeFarmCheck.growthSpeed.normal;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ if (world.plazmaConfig().block.optimizeFarmCheck.skipMiddleAgingStageForCrops) {
|
|
||||||
+ growthSpeed = growthSpeed / getMaxAge();
|
|
||||||
+ age = getMaxAge() - 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (random.nextFloat() >= (modifier / (100.0f * Math.floor((25.0F / growthSpeed) + 1)))) return;
|
|
||||||
+ if (!CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(age + 1), 2)) return;
|
|
||||||
+ if (!moist || age + 1 != this.getMaxAge() || FarmBlock.isNearWater(world, current)) return;
|
|
||||||
+
|
|
||||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, current, currentState.setValue(FarmBlock.MOISTURE, 0), 2);
|
|
||||||
+ return;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ float growthSpeed = CropBlock.getGrowthSpeed(this, world, pos);
|
|
||||||
+
|
|
||||||
+ if (random.nextFloat() < (modifier / (100.0f * Math.floor((25.0F / growthSpeed) + 1))))
|
|
||||||
+ CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(age + 1), 2);
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Optimize Farm checks
|
|
||||||
}
|
|
||||||
|
|
||||||
public void growCrops(Level world, BlockPos pos, BlockState state) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
|
|
||||||
index d0ec0722496ed931b48c4e7076fddbb1ed36e111..b91afbc90c138ebb7f8722934f59f953642196c9 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
|
|
||||||
@@ -92,7 +92,19 @@ public class FarmBlock extends Block {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
|
||||||
- int i = (Integer) state.getValue(FarmBlock.MOISTURE);
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Optimize Farm checks
|
|
||||||
+ int i = state.getValue(FarmBlock.MOISTURE);
|
|
||||||
+ if (world.plazmaConfig().block.optimizeFarmCheck.enabled) {
|
|
||||||
+ if (i != 0) return;
|
|
||||||
+
|
|
||||||
+ if (isNearWater(world, pos))
|
|
||||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, pos, state.setValue(MOISTURE, 7), 2);
|
|
||||||
+ else
|
|
||||||
+ turnToDirt(null, state, world, pos);
|
|
||||||
+
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Optimize Farm checks
|
|
||||||
if (i > 0 && world.paperConfig().tickRates.wetFarmland != 1 && (world.paperConfig().tickRates.wetFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.wetFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks
|
|
||||||
if (i == 0 && world.paperConfig().tickRates.dryFarmland != 1 && (world.paperConfig().tickRates.dryFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.dryFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks
|
|
||||||
|
|
||||||
@@ -167,7 +179,7 @@ public class FarmBlock extends Block {
|
|
||||||
return world.getBlockState(pos.above()).is(BlockTags.MAINTAINS_FARMLAND);
|
|
||||||
}
|
|
||||||
|
|
||||||
- private static boolean isNearWater(LevelReader world, BlockPos pos) {
|
|
||||||
+ static boolean isNearWater(LevelReader world, BlockPos pos) { // Plazma - AT (private -> package)
|
|
||||||
// Paper start - Perf: remove abstract block iteration
|
|
||||||
int xOff = pos.getX();
|
|
||||||
int yOff = pos.getY();
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/StemBlock.java b/src/main/java/net/minecraft/world/level/block/StemBlock.java
|
|
||||||
index 924d80eb41d9a71d1e521c40742557251cf51832..4a30e1e6eac4b0e3dc2147a74e73e05fa76f5db2 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/StemBlock.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/StemBlock.java
|
|
||||||
@@ -72,38 +72,82 @@ public class StemBlock extends BushBlock implements BonemealableBlock {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
|
||||||
- if (world.getRawBrightness(pos, 0) >= 9) {
|
|
||||||
- float f = CropBlock.getGrowthSpeed(this, world, pos);
|
|
||||||
-
|
|
||||||
- if (random.nextFloat() < ((this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
|
|
||||||
- int i = (Integer) state.getValue(StemBlock.AGE);
|
|
||||||
-
|
|
||||||
- if (i < 7) {
|
|
||||||
- state = (BlockState) state.setValue(StemBlock.AGE, i + 1);
|
|
||||||
- CraftEventFactory.handleBlockGrowEvent(world, pos, state, 2); // CraftBukkit
|
|
||||||
- } else {
|
|
||||||
- Direction enumdirection = Direction.Plane.HORIZONTAL.getRandomDirection(random);
|
|
||||||
- BlockPos blockposition1 = pos.relative(enumdirection);
|
|
||||||
- BlockState iblockdata1 = world.getBlockState(blockposition1.below());
|
|
||||||
-
|
|
||||||
- if (world.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is(BlockTags.DIRT))) {
|
|
||||||
- Registry<Block> iregistry = world.registryAccess().registryOrThrow(Registries.BLOCK);
|
|
||||||
- Optional<Block> optional = iregistry.getOptional(this.fruit);
|
|
||||||
- Optional<Block> optional1 = iregistry.getOptional(this.attachedStem);
|
|
||||||
-
|
|
||||||
- if (optional.isPresent() && optional1.isPresent()) {
|
|
||||||
- // CraftBukkit start
|
|
||||||
- if (!CraftEventFactory.handleBlockGrowEvent(world, blockposition1, ((Block) optional.get()).defaultBlockState())) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- // CraftBukkit end
|
|
||||||
- world.setBlockAndUpdate(pos, (BlockState) ((Block) optional1.get()).defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, enumdirection));
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Optimize Farm checks
|
|
||||||
+ if (world.getRawBrightness(pos, 0) < 9) return;
|
|
||||||
+
|
|
||||||
+ int modifier = this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier;
|
|
||||||
+
|
|
||||||
+ if (world.plazmaConfig().block.optimizeFarmCheck.enabled) {
|
|
||||||
+ final BlockPos current = pos.below();
|
|
||||||
+ final BlockState currentState = world.getBlockState(current);
|
|
||||||
+
|
|
||||||
+ final boolean moist;
|
|
||||||
+ final float growthSpeed;
|
|
||||||
+ if (currentState.is(Blocks.FARMLAND) && currentState.getValue(FarmBlock.MOISTURE) > 0) {
|
|
||||||
+ moist = true;
|
|
||||||
+ growthSpeed = world.plazmaConfig().block.optimizeFarmCheck.growthSpeed.moist;
|
|
||||||
+ } else {
|
|
||||||
+ moist = false;
|
|
||||||
+ growthSpeed = world.plazmaConfig().block.optimizeFarmCheck.growthSpeed.normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (random.nextFloat() >= (modifier / (100.0f * Math.floor((25.0F / growthSpeed) + 1)))) return;
|
|
||||||
+
|
|
||||||
+ int age = state.getValue(AGE);
|
|
||||||
+
|
|
||||||
+ if (age < 7) {
|
|
||||||
+ CraftEventFactory.handleMoistureChangeEvent(world, pos, state.setValue(AGE, age + 1), 2);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ Direction direction = Direction.Plane.HORIZONTAL.getRandomDirection(random);
|
|
||||||
+ BlockPos pos1 = pos.relative(direction);
|
|
||||||
+ BlockState state1 = world.getBlockState(pos1.below());
|
|
||||||
+
|
|
||||||
+ if (!world.getBlockState(pos1).isAir() || (!state1.is(Blocks.FARMLAND) && !state1.is(BlockTags.DIRT)))
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ Registry<Block> registry = world.registryAccess().registryOrThrow(Registries.BLOCK);
|
|
||||||
+ Optional<Block> fruit = registry.getOptional(this.fruit);
|
|
||||||
+ Optional<Block> stem = registry.getOptional(this.attachedStem);
|
|
||||||
+
|
|
||||||
+ if (fruit.isEmpty() || stem.isEmpty()) return;
|
|
||||||
+ if (!CraftEventFactory.handleBlockGrowEvent(world, pos1, fruit.get().defaultBlockState())) return;
|
|
||||||
+ if (moist && !FarmBlock.isNearWater(world, current))
|
|
||||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, current, currentState.setValue(FarmBlock.MOISTURE, 0), 2);
|
|
||||||
+
|
|
||||||
+ world.setBlockAndUpdate(pos, stem.get().defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, direction));
|
|
||||||
+ return;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ float f = CropBlock.getGrowthSpeed(this, world, pos);
|
|
||||||
+
|
|
||||||
+ if (random.nextFloat() >= (modifier / (100.0f * Math.floor((25.0F / f) + 1)))) return;
|
|
||||||
+
|
|
||||||
+ int age = state.getValue(StemBlock.AGE);
|
|
||||||
+
|
|
||||||
+ if (age < 7) {
|
|
||||||
+ CraftEventFactory.handleBlockGrowEvent(world, pos, state.setValue(StemBlock.AGE, age + 1), 2);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ Direction direction = Direction.Plane.HORIZONTAL.getRandomDirection(random);
|
|
||||||
+ BlockPos pos1 = pos.relative(direction);
|
|
||||||
+ BlockState state1 = world.getBlockState(pos1.below());
|
|
||||||
+
|
|
||||||
+ if (!world.getBlockState(pos1).isAir() || (!state1.is(Blocks.FARMLAND) && !state1.is(BlockTags.DIRT))) return;
|
|
||||||
+
|
|
||||||
+ Registry<Block> registry = world.registryAccess().registryOrThrow(Registries.BLOCK);
|
|
||||||
+ Optional<Block> fruit = registry.getOptional(this.fruit);
|
|
||||||
+ Optional<Block> stem = registry.getOptional(this.attachedStem);
|
|
||||||
+
|
|
||||||
+ if (fruit.isEmpty() || stem.isEmpty()) return;
|
|
||||||
+
|
|
||||||
+ if (!CraftEventFactory.handleBlockGrowEvent(world, pos1, fruit.get().defaultBlockState()))
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ world.setBlockAndUpdate(pos, stem.get().defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, direction));
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Optimize Farm checks
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java
|
|
||||||
index 28e3b73507b988f7234cbf29c4024c88180d0aef..6239c171ca996f3f5c23060f728a62236bc8b6d5 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java
|
|
||||||
@@ -10,4 +10,6 @@ public interface TickingBlockEntity {
|
|
||||||
BlockPos getPos();
|
|
||||||
|
|
||||||
String getType();
|
|
||||||
+
|
|
||||||
+ long getChunkCoordinateKey(); // Plazma - Port SparklyPaper patches; Optimize tickingBlockEntities
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
||||||
index 75c8125e20b70433fe9d143a3193d821043327c3..d6005f01057c9d14fe4a019df67967db71c908ef 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
||||||
@@ -66,6 +66,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
|
|
||||||
protected volatile boolean unsaved;
|
|
||||||
private volatile boolean isLightCorrect;
|
|
||||||
protected final ChunkPos chunkPos; public final long coordinateKey; public final int locX; public final int locZ; // Paper - cache coordinate key
|
|
||||||
+ public final long nearbyPlayersCoordinateKey; // Plazma - Port SparklyPaper patches; Cache coordinate key used for nearby players when ticking chunks
|
|
||||||
private long inhabitedTime;
|
|
||||||
/** @deprecated */
|
|
||||||
@Nullable
|
|
||||||
@@ -144,6 +145,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
|
|
||||||
public ChunkAccess(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor heightLimitView, Registry<Biome> biomeRegistry, long inhabitedTime, @Nullable LevelChunkSection[] sectionArray, @Nullable BlendingData blendingData) {
|
|
||||||
this.locX = pos.x; this.locZ = pos.z; // Paper - reduce need for field lookups
|
|
||||||
this.chunkPos = pos; this.coordinateKey = ChunkPos.asLong(locX, locZ); // Paper - cache long key
|
|
||||||
+ this.nearbyPlayersCoordinateKey = io.papermc.paper.util.CoordinateUtils.getChunkKey(locX, locZ); // Plazma - Port SparklyPaper patches; Cache coordinate key used for nearby players when ticking chunks
|
|
||||||
this.upgradeData = upgradeData;
|
|
||||||
this.levelHeightAccessor = heightLimitView;
|
|
||||||
this.sections = new LevelChunkSection[heightLimitView.getSectionsCount()];
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
|
||||||
index a4578ae22409edb686d0bcbac8cbc1a2e1d7b988..87f781e94c9a99a7592cc44507fc7ab8d465c5b6 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
|
||||||
@@ -74,6 +74,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
||||||
public String getType() {
|
|
||||||
return "<null>";
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ @Override public long getChunkCoordinateKey() { return 0; } // Plazma - Port SparklyPaper patches; Optimize tickingBlockEntities
|
|
||||||
};
|
|
||||||
private final Map<BlockPos, LevelChunk.RebindableTickingBlockEntityWrapper> tickersInLevel;
|
|
||||||
public boolean loaded;
|
|
||||||
@@ -966,7 +968,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends BlockEntity> TickingBlockEntity createTicker(T blockEntity, BlockEntityTicker<T> blockEntityTicker) {
|
|
||||||
- return new LevelChunk.BoundTickingBlockEntity<>(blockEntity, blockEntityTicker);
|
|
||||||
+ return new LevelChunk.BoundTickingBlockEntity<>(blockEntity, blockEntityTicker, this.coordinateKey); // Plazma - Port SparklyPaper patches; Optimize TickingBlockEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
@@ -1017,6 +1019,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
||||||
public String toString() {
|
|
||||||
return String.valueOf(this.ticker) + " <wrapped>";
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ @Override public long getChunkCoordinateKey() { return this.ticker.getChunkCoordinateKey(); } // Plazma - Port SparklyPaper patches; Optimize TickingBlockEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
private class BoundTickingBlockEntity<T extends BlockEntity> implements TickingBlockEntity {
|
|
||||||
@@ -1025,7 +1029,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
||||||
private final BlockEntityTicker<T> ticker;
|
|
||||||
private boolean loggedInvalidBlockState;
|
|
||||||
|
|
||||||
- BoundTickingBlockEntity(final BlockEntity tileentity, final BlockEntityTicker blockentityticker) {
|
|
||||||
+ BoundTickingBlockEntity(final BlockEntity tileentity, final BlockEntityTicker blockentityticker, long chunkCoordinateKey) { // Plazma - Port SparklyPaper patches; Optimize TickingBlockEntity
|
|
||||||
this.blockEntity = (T) tileentity; // CraftBukkit - decompile error
|
|
||||||
this.ticker = blockentityticker;
|
|
||||||
}
|
|
||||||
@@ -1095,5 +1099,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
||||||
|
|
||||||
return "Level ticker for " + s + "@" + String.valueOf(this.getPos());
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ @Override public long getChunkCoordinateKey() { return this.chunkCoordinateKey; } // Plazma - Port SparklyPaper patches; Optimize TickingBlockEntity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/sparklypower/sparklypaper/HalloweenManager.java b/src/main/java/net/sparklypower/sparklypaper/HalloweenManager.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..f8c26e26025d7a7b5489ed5b3274ba734db27a1d
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/net/sparklypower/sparklypaper/HalloweenManager.java
|
|
||||||
@@ -0,0 +1,78 @@
|
|
||||||
+package net.sparklypower.sparklypaper;
|
|
||||||
+
|
|
||||||
+import com.mojang.logging.LogUtils;
|
|
||||||
+import it.unimi.dsi.fastutil.Pair;
|
|
||||||
+import net.minecraft.world.level.Level;
|
|
||||||
+import org.slf4j.Logger;
|
|
||||||
+import java.time.LocalDateTime;
|
|
||||||
+import java.time.Month;
|
|
||||||
+import java.time.ZoneOffset;
|
|
||||||
+import java.util.concurrent.CountDownLatch;
|
|
||||||
+import java.util.concurrent.Executors;
|
|
||||||
+import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
+import java.util.concurrent.ScheduledFuture;
|
|
||||||
+import java.util.concurrent.TimeUnit;
|
|
||||||
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
+
|
|
||||||
+import static org.plazmamc.plazma.configurations.GlobalConfiguration.get;
|
|
||||||
+
|
|
||||||
+public class HalloweenManager {
|
|
||||||
+
|
|
||||||
+ private static final Logger LOGGER = LogUtils.getClassLogger();
|
|
||||||
+ private static final ScheduledExecutorService EXECUTOR = Executors.newSingleThreadScheduledExecutor(factory -> {
|
|
||||||
+ Thread thread = new Thread(factory);
|
|
||||||
+ thread.setName("halloween-timer-updater");
|
|
||||||
+ thread.setPriority(1);
|
|
||||||
+ return thread;
|
|
||||||
+ });
|
|
||||||
+
|
|
||||||
+ private static ScheduledFuture<?> future;
|
|
||||||
+ private static Pair<Long, Long> spookyEpoch;
|
|
||||||
+ private static Pair<Long, Long> halloweenEpoch;
|
|
||||||
+
|
|
||||||
+ private static long getEpochMillisAtDate(Month month, int day, boolean start) {
|
|
||||||
+ LocalDateTime now = LocalDateTime.now();
|
|
||||||
+ LocalDateTime target = LocalDateTime.of(
|
|
||||||
+ now.getYear(), month, day, start ? 0 : 23, start ? 0 : 59, start ? 0 : 59, start ? 0 : 999_999_999
|
|
||||||
+ );
|
|
||||||
+
|
|
||||||
+ if (now.isAfter(target)) target = target.plusYears(1);
|
|
||||||
+ return target.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static void syncEpoch() {
|
|
||||||
+ LOGGER.info("Updating Spooky Season and Halloween epoch...");
|
|
||||||
+ spookyEpoch = Pair.of(
|
|
||||||
+ getEpochMillisAtDate(Month.OCTOBER, 20, true),
|
|
||||||
+ getEpochMillisAtDate(Month.NOVEMBER, 3, false)
|
|
||||||
+ );
|
|
||||||
+ halloweenEpoch = Pair.of(
|
|
||||||
+ getEpochMillisAtDate(Month.OCTOBER, 31, true),
|
|
||||||
+ getEpochMillisAtDate(Month.OCTOBER, 31, false)
|
|
||||||
+ );
|
|
||||||
+ LOGGER.info("Successfully updated Spooky Season and Halloween epoch");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static void syncConfiguration() {
|
|
||||||
+ if (get().entity.spookyOptimize && future == null) {
|
|
||||||
+ startSyncEpochTask();
|
|
||||||
+ } else if (!get().entity.spookyOptimize && future != null) {
|
|
||||||
+ future.cancel(true);
|
|
||||||
+ future = null;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static void startSyncEpochTask() {
|
|
||||||
+ if (!get().entity.spookyOptimize) return;
|
|
||||||
+ future = EXECUTOR.scheduleAtFixedRate(HalloweenManager::syncEpoch, 0, 90, TimeUnit.DAYS);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static boolean isSpookySeason() {
|
|
||||||
+ return spookyEpoch.first() <= System.currentTimeMillis() && System.currentTimeMillis() <= spookyEpoch.second();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static boolean isHalloween() {
|
|
||||||
+ return halloweenEpoch.first() <= System.currentTimeMillis() && System.currentTimeMillis() <= halloweenEpoch.second();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
||||||
index 173e4a075078af67f030750c9a6294ab3f796677..92ad49e0ff5dc17bc8e181578ff93bc96e3503ef 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
||||||
@@ -978,7 +978,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
||||||
public void sendMultiBlockChange(final Map<? extends io.papermc.paper.math.Position, BlockData> blockChanges) {
|
|
||||||
if (this.getHandle().connection == null) return;
|
|
||||||
|
|
||||||
- Map<SectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<net.minecraft.world.level.block.state.BlockState>> sectionMap = new HashMap<>();
|
|
||||||
+ Map<SectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<net.minecraft.world.level.block.state.BlockState>> sectionMap = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // Plazma - Port SparklyPaper patches; Optimize canSee checks
|
|
||||||
|
|
||||||
for (Map.Entry<? extends io.papermc.paper.math.Position, BlockData> entry : blockChanges.entrySet()) {
|
|
||||||
BlockData blockData = entry.getValue();
|
|
||||||
@@ -2259,9 +2259,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canSee(org.bukkit.entity.Entity entity) {
|
|
||||||
- return this.equals(entity) || entity.isVisibleByDefault() ^ this.invertedVisibilityEntities.containsKey(entity.getUniqueId()); // SPIGOT-7312: Can always see self
|
|
||||||
+ return this.equals(entity) || this.chunkMapCanSee(entity); // SPIGOT-7312: Can always see self // Plazma - Port SparklyPaper patches; Optimize canSee check
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Plazma start - Port SparklyPaper patches; Optimize canSee check (The check in ChunkMap#updatePlayer already rejects if it is the same entity, so we don't need to check it twice, especially because CraftPlayer's equals check is a bit expensive)
|
|
||||||
+ public boolean chunkMapCanSee(org.bukkit.entity.Entity entity) {
|
|
||||||
+ return entity.isVisibleByDefault() ^ (!invertedVisibilityEntities.isEmpty() && this.invertedVisibilityEntities.containsKey(entity.getUniqueId()));
|
|
||||||
+ }
|
|
||||||
+ // Plazma end - Port SparklyPaper patches; Optimize canSee check
|
|
||||||
+
|
|
||||||
public boolean canSeePlayer(UUID uuid) {
|
|
||||||
org.bukkit.entity.Entity entity = this.getServer().getPlayer(uuid);
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
|
||||||
index 8149b9c51b78eb5c689b7218a2ca3aab60e73bcf..b9a303f6280a2f6ad3616da152922a4f4a504281 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
|
||||||
@@ -145,7 +145,7 @@ public class CraftMapColorCache implements MapPalette.MapColorCache {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
- public boolean isCached() {
|
|
||||||
+ public synchronized boolean isCached() { // Plazma - Fix concurrency issues when using "imageToBytes" in multiple threads
|
|
||||||
return this.cached || (!this.running.get() && this.initCache().isDone());
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
index 57d29f8f3bc89529db9ee8f6dc3fffdbd4a03ceb..73dd69941a004b4a2ec244f28d8683e9bdb0a445 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
@@ -40,9 +40,12 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|
||||||
public Entity entity;
|
|
||||||
public class Entity extends ConfigurationPart {
|
|
||||||
|
|
||||||
+ boolean skipSqrWhenNoDeltaChanges = OPTIMIZE;
|
|
||||||
+ public boolean spookyOptimize = OPTIMIZE;
|
|
||||||
|
|
||||||
@PostProcess
|
|
||||||
public void post() {
|
|
||||||
+ net.minecraft.server.level.ServerEntity.skipSqrWhenNoDeltaChanges = this.skipSqrWhenNoDeltaChanges;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -50,9 +53,11 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|
||||||
public World world;
|
|
||||||
public class World extends ConfigurationPart {
|
|
||||||
|
|
||||||
+ boolean skipTickWhenCraftNotPresent = OPTIMIZE;
|
|
||||||
|
|
||||||
@PostProcess
|
|
||||||
public void post() {
|
|
||||||
+ net.minecraft.world.item.MapItem.skipTickWhenCraftNotPresent = this.skipTickWhenCraftNotPresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
index 8dce68cf7769fcd5ea03be32621ccb6bab174697..069a9f8504c74d939b1df569f082cc7bd33d9cfc 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
@@ -49,7 +49,22 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
||||||
|
|
||||||
public Block block;
|
|
||||||
public class Block extends ConfigurationPart {
|
|
||||||
-
|
|
||||||
+
|
|
||||||
+ public OptimizeFarmCheck optimizeFarmCheck;
|
|
||||||
+ public class OptimizeFarmCheck extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+ public boolean enabled = OPTIMIZE;
|
|
||||||
+ public boolean skipMiddleAgingStageForCrops = true;
|
|
||||||
+
|
|
||||||
+ public GrowthSpeed growthSpeed;
|
|
||||||
+ public class GrowthSpeed extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+ public int normal = 1;
|
|
||||||
+ public int moist = 4;
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 5 Nov 2023 10:13:14 +0900
|
|
||||||
Subject: [PATCH] Always agree EULA on development mode
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
|
||||||
index ac2f6591dc6130f1877703c804a1359f3262f803..639a0624f5e746b9a876d62c3215c7856931deea 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/Main.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
|
||||||
@@ -167,6 +167,7 @@ public class Main {
|
|
||||||
|
|
||||||
// Spigot Start
|
|
||||||
boolean eulaAgreed = Boolean.getBoolean( "com.mojang.eula.agree" );
|
|
||||||
+ eulaAgreed = eulaAgreed || Boolean.getBoolean("Paper.pushPaperAssetsRoot"); // Plazma - Always agree EULA on development mode
|
|
||||||
if ( eulaAgreed )
|
|
||||||
{
|
|
||||||
System.err.println( "You have used the Spigot command line EULA agreement flag." );
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 5 Nov 2023 10:26:26 +0900
|
|
||||||
Subject: [PATCH] Add more metrics
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
||||||
index 81b204c03b3c9a997f00fd423daa963757cb0daf..67e299893b7e1a64ab2962d79c2434dad189eed5 100644
|
|
||||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
|
||||||
@@ -636,38 +636,59 @@ public class Metrics {
|
|
||||||
return map;
|
|
||||||
}));
|
|
||||||
|
|
||||||
- metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> {
|
|
||||||
- Map<String, Map<String, Integer>> map = new HashMap<>();
|
|
||||||
+ // Plazma start - Add more metrics information
|
|
||||||
+ metrics.addCustomChart(new DrilldownPie("datapacks", () -> {
|
|
||||||
+ int datapacks = Bukkit.getDatapackManager().getEnabledPacks().size();
|
|
||||||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(datapacks), 1);
|
|
||||||
+
|
|
||||||
+ if (datapacks == 0) return Collections.singletonMap("0", entry);
|
|
||||||
+ else if (datapacks <= 5) return Collections.singletonMap("1-5", entry);
|
|
||||||
+ else if (datapacks <= 10) return Collections.singletonMap("6-10", entry);
|
|
||||||
+ else if (datapacks <= 25) return Collections.singletonMap("11-25", entry);
|
|
||||||
+ else if (datapacks <= 50) return Collections.singletonMap("26-50", entry);
|
|
||||||
+ else if (datapacks <= 100) return Collections.singletonMap("51+", entry);
|
|
||||||
+ else return Collections.singletonMap("101+ \uD83D\uDE2E", entry);
|
|
||||||
+ }));
|
|
||||||
|
|
||||||
- // count legacy plugins
|
|
||||||
- int legacy = 0;
|
|
||||||
- for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
|
||||||
- if (CraftMagicNumbers.isLegacy(plugin.getDescription())) {
|
|
||||||
- legacy++;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+ metrics.addCustomChart(new DrilldownPie("plugins", () -> {
|
|
||||||
+ int pluginCount = Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(Plugin::isEnabled).toList().size();
|
|
||||||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(pluginCount), 1);
|
|
||||||
+
|
|
||||||
+ if (pluginCount == 0) return Collections.singletonMap("0", entry);
|
|
||||||
+ else if (pluginCount <= 5) return Collections.singletonMap("1-5", entry);
|
|
||||||
+ else if (pluginCount <= 10) return Collections.singletonMap("6-10", entry);
|
|
||||||
+ else if (pluginCount <= 25) return Collections.singletonMap("11-25", entry);
|
|
||||||
+ else if (pluginCount <= 50) return Collections.singletonMap("26-50", entry);
|
|
||||||
+ else if (pluginCount <= 100) return Collections.singletonMap("51-100", entry);
|
|
||||||
+ else return Collections.singletonMap("101+ \uD83D\uDE2E", entry);
|
|
||||||
+ }));
|
|
||||||
|
|
||||||
- // insert real value as lower dimension
|
|
||||||
- Map<String, Integer> entry = new HashMap<>();
|
|
||||||
- entry.put(String.valueOf(legacy), 1);
|
|
||||||
-
|
|
||||||
- // create buckets as higher dimension
|
|
||||||
- if (legacy == 0) {
|
|
||||||
- map.put("0 \uD83D\uDE0E", entry); // :sunglasses:
|
|
||||||
- } else if (legacy <= 5) {
|
|
||||||
- map.put("1-5", entry);
|
|
||||||
- } else if (legacy <= 10) {
|
|
||||||
- map.put("6-10", entry);
|
|
||||||
- } else if (legacy <= 25) {
|
|
||||||
- map.put("11-25", entry);
|
|
||||||
- } else if (legacy <= 50) {
|
|
||||||
- map.put("26-50", entry);
|
|
||||||
- } else {
|
|
||||||
- map.put("50+ \uD83D\uDE2D", entry); // :cry:
|
|
||||||
- }
|
|
||||||
+ metrics.addCustomChart(new DrilldownPie("disabled_plugins", () -> {
|
|
||||||
+ int disabled = Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(it -> !it.isEnabled()).toList().size();
|
|
||||||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(disabled), 1);
|
|
||||||
+
|
|
||||||
+ if (disabled == 0) return Collections.singletonMap("0 \uD83D\uDE0E", entry); // :sunglasses:
|
|
||||||
+ else if (disabled <= 5) return Collections.singletonMap("1-5", entry);
|
|
||||||
+ else if (disabled <= 10) return Collections.singletonMap("6-10", entry);
|
|
||||||
+ else if (disabled <= 25) return Collections.singletonMap("11-25", entry);
|
|
||||||
+ else if (disabled <= 50) return Collections.singletonMap("26-50", entry);
|
|
||||||
+ else if (disabled <= 100) return Collections.singletonMap("51-100 \uD83D\uDE2D", entry); // :cry:
|
|
||||||
+ else return Collections.singletonMap("101+ \uD83D\uDC80", entry); // :skull:
|
|
||||||
+ }));
|
|
||||||
|
|
||||||
- return map;
|
|
||||||
+ metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> {
|
|
||||||
+ int legacy = (int) Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(p -> CraftMagicNumbers.isLegacy(p.getDescription())).count(); // Plazma
|
|
||||||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(legacy), 1);
|
|
||||||
+
|
|
||||||
+ if (legacy == 0) return Collections.singletonMap("0 \uD83D\uDE0E", entry); // :sunglasses:
|
|
||||||
+ else if (legacy <= 5) return Collections.singletonMap("1-5", entry);
|
|
||||||
+ else if (legacy <= 10) return Collections.singletonMap("6-10", entry);
|
|
||||||
+ else if (legacy <= 25) return Collections.singletonMap("11-25", entry);
|
|
||||||
+ else if (legacy <= 50) return Collections.singletonMap("26-50", entry);
|
|
||||||
+ else if (legacy <= 100) return Collections.singletonMap("51-100 \uD83D\uDE2D", entry); // :cry:
|
|
||||||
+ else return Collections.singletonMap("101+ \uD83D\uDC80", entry); // :skull:
|
|
||||||
}));
|
|
||||||
+ // Plazma end - Add more metrics information
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 5 Nov 2023 10:40:49 +0900
|
|
||||||
Subject: [PATCH] Tweak console logging
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
index f6afc085b903fe0a71109792593da21b665a5300..dea61aeaf8b444c71fb54459b09486a9853772d1 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
@@ -197,16 +197,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
||||||
DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
- // Paper start - detect running as root
|
|
||||||
- if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) {
|
|
||||||
- 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.");
|
|
||||||
- DedicatedServer.LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/");
|
|
||||||
- DedicatedServer.LOGGER.warn("****************************");
|
|
||||||
- }
|
|
||||||
- // Paper end - detect running as root
|
|
||||||
-
|
|
||||||
DedicatedServer.LOGGER.info("Loading properties");
|
|
||||||
DedicatedServerProperties dedicatedserverproperties = this.settings.getProperties();
|
|
||||||
|
|
||||||
@@ -239,6 +229,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
||||||
this.plazmaConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); // Plazma - Configurable Plazma
|
|
||||||
net.sparklypower.sparklypaper.HalloweenManager.startSyncEpochTask(); // Plazma - Port SparklyPaper patches; Optimize Spooky Season
|
|
||||||
// Paper end - initialize global and world-defaults configuration
|
|
||||||
+ // Paper start - detect running as root // Plazma - Tweak console logging (moved down)
|
|
||||||
+ if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) {
|
|
||||||
+ 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.");
|
|
||||||
+ DedicatedServer.LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/");
|
|
||||||
+ DedicatedServer.LOGGER.warn("****************************");
|
|
||||||
+ }
|
|
||||||
+ // Paper end - detect running as root
|
|
||||||
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()) {
|
|
||||||
@@ -339,6 +338,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 (org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.offlineWarnings && !(io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.onlineMode)) // Plazma - Tweak console logging
|
|
||||||
if (!this.usesAuthentication()) {
|
|
||||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
|
||||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
|
||||||
@@ -352,7 +352,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
||||||
DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
|
|
||||||
}
|
|
||||||
// Spigot end
|
|
||||||
- DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
|
||||||
+ DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file or set \"console-logs.offline-warnings\" to \"false\" in the config/plazma-global.yml file."); // Plazma - Tweak console logging
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
||||||
index 0ea07da1b4bd420cd6765577b4719a2368b5740c..f78a0a224c86c0e3e5a44ce4f589cd8a61c546f9 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
||||||
@@ -1462,6 +1462,7 @@ public abstract class PlayerList {
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public
|
|
||||||
+ if (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.notSecurePrefix) return true; // Plazma - Tweak console logging
|
|
||||||
return message.hasSignature() && !message.hasExpiredServer(Instant.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
index 73dd69941a004b4a2ec244f28d8683e9bdb0a445..e725f6e8205976a7b137aefb98b874cf4ae14893 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
@@ -68,4 +68,13 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
+ public ConsoleLogs consoleLogs;
|
|
||||||
+ public class ConsoleLogs extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+ public boolean offlineWarnings = true;
|
|
||||||
+ public boolean rootUserWarnings = true;
|
|
||||||
+ public boolean notSecurePrefix = true;
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 5 Nov 2023 11:27:51 +0900
|
|
||||||
Subject: [PATCH] Add option to change nether portal size
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalShape.java b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
|
||||||
index 6c07fc507df6070854f5950a8616d2949c040656..19f58609aedecec1ea1a552c135a0b4199ab5c2a 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
|
||||||
@@ -97,7 +97,7 @@ public class PortalShape {
|
|
||||||
private int calculateWidth() {
|
|
||||||
int i = this.getDistanceUntilEdgeAboveFrame(this.bottomLeft, this.rightDir);
|
|
||||||
|
|
||||||
- return i >= 2 && i <= 21 ? i : 0;
|
|
||||||
+ return i >= this.level.getMinecraftWorld().plazmaConfig().structure.netherPortal.width.min() && i <= this.level.getMinecraftWorld().plazmaConfig().structure.netherPortal.width.max() ? i : 0; // Plazma - Configurable nether portal size
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getDistanceUntilEdgeAboveFrame(BlockPos pos, Direction direction) {
|
|
||||||
@@ -130,7 +130,7 @@ public class PortalShape {
|
|
||||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
|
||||||
int i = this.getDistanceUntilTop(blockposition_mutableblockposition);
|
|
||||||
|
|
||||||
- return i >= 3 && i <= 21 && this.hasTopFrame(blockposition_mutableblockposition, i) ? i : 0;
|
|
||||||
+ return i >= this.level.getMinecraftWorld().plazmaConfig().structure.netherPortal.height.min() && i <= this.level.getMinecraftWorld().plazmaConfig().structure.netherPortal.height.max() && this.hasTopFrame(blockposition_mutableblockposition, i) ? i : 0; // Plazma - Configurable nether portal size
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasTopFrame(BlockPos.MutableBlockPos pos, int height) {
|
|
||||||
@@ -184,7 +184,7 @@ public class PortalShape {
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid() {
|
|
||||||
- return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
|
|
||||||
+ return this.bottomLeft != null && this.width >= this.level.getMinecraftWorld().plazmaConfig().structure.netherPortal.width.min() && this.width <= this.level.getMinecraftWorld().plazmaConfig().structure.netherPortal.width.max() && this.height >= this.level.getMinecraftWorld().plazmaConfig().structure.netherPortal.height.min() && this.height <= this.level.getMinecraftWorld().plazmaConfig().structure.netherPortal.height.max(); // Plazma - Configurable nether portal size
|
|
||||||
}
|
|
||||||
|
|
||||||
// CraftBukkit start - return boolean, add entity
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
index 069a9f8504c74d939b1df569f082cc7bd33d9cfc..b5b4229ccdecd63bd3e689e8247e44341d7c30cc 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
@@ -42,6 +42,21 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
||||||
public NetherPortal netherPortal;
|
|
||||||
public class NetherPortal extends ConfigurationPart {
|
|
||||||
|
|
||||||
+ public Width width;
|
|
||||||
+ public class Width extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+ int min = 2; public int min() { return Math.max(this.min, 1); }
|
|
||||||
+ int max = 21; public int max() { return Math.max(this.min, this.max); }
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public Height height;
|
|
||||||
+ public class Height extends ConfigurationPart {
|
|
||||||
+
|
|
||||||
+ int min = 3; public int min() { return Math.max(this.min, 2); }
|
|
||||||
+ int max = 21; public int max() { return Math.max(this.min, this.max); }
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
Date: Sat, 25 Mar 2023 00:52:11 +0900
|
Date: Sat, 25 Mar 2023 00:52:11 +0900
|
||||||
Subject: [PATCH] Add missing purpur configuration options
|
Subject: [PATCH] Add missing Purpur configuration options
|
||||||
|
|
||||||
|
|
||||||
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
|
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 62c62fd26..43791817a 100644
|
index 67ff60909dee395d42619c310bafc381b9bfce5d..42fc51827240f9f0091e006fa84a17c2fb51dddd 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
+++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||||
@@ -158,6 +158,23 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
@@ -162,6 +162,18 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.allayMaxHealth);
|
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.allayMaxHealth);
|
||||||
this.getAttribute(Attributes.SCALE).setBaseValue(this.level().purpurConfig.allayScale);
|
this.getAttribute(Attributes.SCALE).setBaseValue(this.level().purpurConfig.allayScale);
|
||||||
}
|
}
|
||||||
@@ -23,20 +23,15 @@ index 62c62fd26..43791817a 100644
|
|||||||
+ public boolean isAlwaysExperienceDropper() {
|
+ public boolean isAlwaysExperienceDropper() {
|
||||||
+ return level().purpurConfig.allayAlwaysDropExp;
|
+ return level().purpurConfig.allayAlwaysDropExp;
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void initAttributes() {
|
|
||||||
+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(level().purpurConfig.allayMaxHealth);
|
|
||||||
+ }
|
|
||||||
+ // Plazma end - Add missing purpur configuration options
|
+ // Plazma end - Add missing purpur configuration options
|
||||||
// Purpur end
|
// Purpur end - Configurable entity base attributes
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
protected Brain.Provider<Allay> brainProvider() {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||||
index e88d6d691..00803dcc2 100644
|
index 36f8bb5cf25566784e11988c91e1c7409f1ac5c8..d364866de67341e4a781b4f2bf3e7c187ee2bc8c 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||||
@@ -96,6 +96,18 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
|
@@ -99,6 +99,18 @@ public class Camel extends AbstractHorse {
|
||||||
public int getPurpurBreedTime() {
|
public int getPurpurBreedTime() {
|
||||||
return this.level().purpurConfig.camelBreedingTicks;
|
return this.level().purpurConfig.camelBreedingTicks;
|
||||||
}
|
}
|
||||||
@@ -52,14 +47,14 @@ index e88d6d691..00803dcc2 100644
|
|||||||
+ return level().purpurConfig.camelAlwaysDropExp;
|
+ return level().purpurConfig.camelAlwaysDropExp;
|
||||||
+ }
|
+ }
|
||||||
+ // Plazma end - Add missing purpur configuration options
|
+ // Plazma end - Add missing purpur configuration options
|
||||||
// Purpur end
|
// Purpur end - Make entity breeding times configurable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public void addAdditionalSaveData(CompoundTag nbt) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||||
index 4c861b18fbfbae3cb2f1e3563393cfcf4005591c..651f30b4fb02dc03fabad34b62d7d86fa0889754 100644
|
index d09aa48e20c9a6e0d465b93e3759556638041394..70772863011ce270bceaf679ea3776fb36d4f0b9 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||||
@@ -160,6 +160,23 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
@@ -163,6 +163,23 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||||
public float getJumpPower() {
|
public float getJumpPower() {
|
||||||
return (getRider() != null && isControllable()) ? level().purpurConfig.frogRidableJumpHeight * this.getBlockJumpFactor() : super.getJumpPower();
|
return (getRider() != null && isControllable()) ? level().purpurConfig.frogRidableJumpHeight * this.getBlockJumpFactor() : super.getJumpPower();
|
||||||
}
|
}
|
||||||
@@ -80,16 +75,16 @@ index 4c861b18fbfbae3cb2f1e3563393cfcf4005591c..651f30b4fb02dc03fabad34b62d7d86f
|
|||||||
+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(level().purpurConfig.frogMaxHealth);
|
+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(level().purpurConfig.frogMaxHealth);
|
||||||
+ }
|
+ }
|
||||||
+ // Plazma end - Add missing purpur configuration options
|
+ // Plazma end - Add missing purpur configuration options
|
||||||
// Purpur end
|
// Purpur end - Ridables
|
||||||
|
|
||||||
public int getPurpurBreedTime() {
|
// Purpur start - Make entity breeding times configurable
|
||||||
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
|
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 5cd69dd54..1abf23fb1 100644
|
index 33429a9afeefce9238969b2894d0a9c033baca51..fee263bd88c19188f6ec8017893dfc12bdd15737 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||||
@@ -93,6 +93,23 @@ public class Tadpole extends AbstractFish {
|
@@ -93,6 +93,23 @@ public class Tadpole extends AbstractFish {
|
||||||
protected void registerGoals() {
|
protected void registerGoals() {
|
||||||
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ // Plazma start - Add missing purpur configuration options
|
+ // Plazma start - Add missing purpur configuration options
|
||||||
@@ -108,14 +103,14 @@ index 5cd69dd54..1abf23fb1 100644
|
|||||||
+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(level().purpurConfig.tadpoleMaxHealth);
|
+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(level().purpurConfig.tadpoleMaxHealth);
|
||||||
+ }
|
+ }
|
||||||
+ // Plazma end - Add missing purpur configuration options
|
+ // Plazma end - Add missing purpur configuration options
|
||||||
// Purpur end
|
// Purpur end - Ridables
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||||
index b6f528170..bc931f54d 100644
|
index 3fa391b638062196675d102b8731a96a51df8e15..86988932dc79e9ca33998044995187709ad5373b 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||||
@@ -120,6 +120,18 @@ public class Sniffer extends Animal {
|
@@ -119,6 +119,18 @@ public class Sniffer extends Animal {
|
||||||
public int getPurpurBreedTime() {
|
public int getPurpurBreedTime() {
|
||||||
return this.level().purpurConfig.snifferBreedingTicks;
|
return this.level().purpurConfig.snifferBreedingTicks;
|
||||||
}
|
}
|
||||||
@@ -131,16 +126,16 @@ index b6f528170..bc931f54d 100644
|
|||||||
+ return level().purpurConfig.snifferAlwaysDropExp;
|
+ return level().purpurConfig.snifferAlwaysDropExp;
|
||||||
+ }
|
+ }
|
||||||
+ // Plazma end - Add missing purpur configuration options
|
+ // Plazma end - Add missing purpur configuration options
|
||||||
// Purpur end
|
// Purpur end - Make entity breeding times configurable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||||
index 8e24cd9ed..c0398f21c 100644
|
index 74011f1ab7e48490109ad93d658bba216eef9e80..5313f4c1ca76b120c0eb6beddc993b562f79344e 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||||
@@ -148,6 +148,23 @@ public class Warden extends Monster implements VibrationSystem {
|
@@ -151,6 +151,23 @@ public class Warden extends Monster implements VibrationSystem {
|
||||||
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
|
||||||
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ // Plazma start - Add missing purpur configuration options
|
+ // Plazma start - Add missing purpur configuration options
|
||||||
@@ -159,29 +154,32 @@ index 8e24cd9ed..c0398f21c 100644
|
|||||||
+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(level().purpurConfig.wardenMaxHealth);
|
+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(level().purpurConfig.wardenMaxHealth);
|
||||||
+ }
|
+ }
|
||||||
+ // Plazma end - Add missing purpur configuration options
|
+ // Plazma end - Add missing purpur configuration options
|
||||||
// Purpur end
|
// Purpur end - Ridables
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
|
@@ -305,7 +322,7 @@ public class Warden extends Monster implements VibrationSystem {
|
||||||
index c14019a13..8b9f78b3b 100644
|
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
|
|
||||||
@@ -45,12 +45,12 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain
|
|
||||||
|
|
||||||
public ChestBoat(EntityType<? extends Boat> type, Level world) {
|
gameprofilerfiller.push("wardenBrain");
|
||||||
super(type, world);
|
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||||
|
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Plazma - Add missing Purpur configurations
|
||||||
|
this.getBrain().tick(world, this);
|
||||||
|
gameprofilerfiller.pop();
|
||||||
|
super.customServerAiStep(world);
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||||
|
index 1f4cc08e84a23213bb9786ea09ad77caeec2d336..f888f1dd2e3c228b0a370fe920b63d547bbba571 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||||
|
@@ -46,7 +46,7 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCusto
|
||||||
|
|
||||||
|
public AbstractChestBoat(EntityType<? extends AbstractChestBoat> type, Level world, Supplier<Item> itemSupplier) {
|
||||||
|
super(type, world, itemSupplier);
|
||||||
- this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY);
|
- this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||||
+ this.itemStacks = NonNullList.withSize(org.purpurmc.purpur.PurpurConfig.chestBoatRows * 9, ItemStack.EMPTY); // Plazma - Add missing purpur configuration options
|
+ this.itemStacks = NonNullList.withSize(org.purpurmc.purpur.PurpurConfig.chestBoatRows * 9, ItemStack.EMPTY); // Plazma - Add missing purpur configuration options
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChestBoat(Level world, double d0, double d1, double d2) {
|
@Override
|
||||||
super(EntityType.CHEST_BOAT, world);
|
@@ -142,7 +142,7 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCusto
|
||||||
- this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY);
|
|
||||||
+ this.itemStacks = NonNullList.withSize(org.purpurmc.purpur.PurpurConfig.chestBoatRows * 9, ItemStack.EMPTY); // Plazma - Add missing purpur configuration options
|
|
||||||
this.setPos(d0, d1, d2);
|
|
||||||
this.xo = d0;
|
|
||||||
this.yo = d1;
|
|
||||||
@@ -177,7 +177,7 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getContainerSize() {
|
public int getContainerSize() {
|
||||||
@@ -191,10 +189,10 @@ index c14019a13..8b9f78b3b 100644
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||||
index 97fc4fb79..cd8194b08 100644
|
index f29059798c9dc642187b4939dd917ee15cbe120d..7a482099a69759659038e10632e7dd4626c187a1 100644
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||||
@@ -330,6 +330,7 @@ public class PurpurConfig {
|
@@ -331,6 +331,7 @@ public class PurpurConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int barrelRows = 3;
|
public static int barrelRows = 3;
|
||||||
@@ -202,7 +200,7 @@ index 97fc4fb79..cd8194b08 100644
|
|||||||
public static boolean enderChestSixRows = false;
|
public static boolean enderChestSixRows = false;
|
||||||
public static boolean enderChestPermissionRows = false;
|
public static boolean enderChestPermissionRows = false;
|
||||||
public static boolean cryingObsidianValidForPortalFrame = false;
|
public static boolean cryingObsidianValidForPortalFrame = false;
|
||||||
@@ -372,6 +373,7 @@ public class PurpurConfig {
|
@@ -373,6 +374,7 @@ public class PurpurConfig {
|
||||||
case 1 -> 9;
|
case 1 -> 9;
|
||||||
default -> 27;
|
default -> 27;
|
||||||
});
|
});
|
||||||
@@ -211,10 +209,10 @@ index 97fc4fb79..cd8194b08 100644
|
|||||||
org.bukkit.event.inventory.InventoryType.ENDER_CHEST.setDefaultSize(enderChestSixRows ? 54 : 27);
|
org.bukkit.event.inventory.InventoryType.ENDER_CHEST.setDefaultSize(enderChestSixRows ? 54 : 27);
|
||||||
enderChestPermissionRows = getBoolean("settings.blocks.ender_chest.use-permissions-for-rows", enderChestPermissionRows);
|
enderChestPermissionRows = getBoolean("settings.blocks.ender_chest.use-permissions-for-rows", enderChestPermissionRows);
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||||
index 1ff95cced..0318c4916 100644
|
index 43ad38dadfe14b3dd0565c536b276eb3f9dbd813..474bab426175d8dece524faeffd8977a6e1bb074 100644
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||||
@@ -1135,7 +1135,13 @@ public class PurpurWorldConfig {
|
@@ -1144,7 +1144,13 @@ public class PurpurWorldConfig {
|
||||||
public boolean allayControllable = true;
|
public boolean allayControllable = true;
|
||||||
public double allayMaxHealth = 20.0D;
|
public double allayMaxHealth = 20.0D;
|
||||||
public double allayScale = 1.0D;
|
public double allayScale = 1.0D;
|
||||||
@@ -228,7 +226,7 @@ index 1ff95cced..0318c4916 100644
|
|||||||
allayRidable = getBoolean("mobs.allay.ridable", allayRidable);
|
allayRidable = getBoolean("mobs.allay.ridable", allayRidable);
|
||||||
allayRidableInWater = getBoolean("mobs.allay.ridable-in-water", allayRidableInWater);
|
allayRidableInWater = getBoolean("mobs.allay.ridable-in-water", allayRidableInWater);
|
||||||
allayControllable = getBoolean("mobs.allay.controllable", allayControllable);
|
allayControllable = getBoolean("mobs.allay.controllable", allayControllable);
|
||||||
@@ -1290,7 +1296,13 @@ public class PurpurWorldConfig {
|
@@ -1299,7 +1305,13 @@ public class PurpurWorldConfig {
|
||||||
public double camelMovementSpeedMin = 0.09D;
|
public double camelMovementSpeedMin = 0.09D;
|
||||||
public double camelMovementSpeedMax = 0.09D;
|
public double camelMovementSpeedMax = 0.09D;
|
||||||
public int camelBreedingTicks = 6000;
|
public int camelBreedingTicks = 6000;
|
||||||
@@ -242,7 +240,7 @@ index 1ff95cced..0318c4916 100644
|
|||||||
camelRidableInWater = getBoolean("mobs.camel.ridable-in-water", camelRidableInWater);
|
camelRidableInWater = getBoolean("mobs.camel.ridable-in-water", camelRidableInWater);
|
||||||
camelMaxHealthMin = getDouble("mobs.camel.attributes.max_health.min", camelMaxHealthMin);
|
camelMaxHealthMin = getDouble("mobs.camel.attributes.max_health.min", camelMaxHealthMin);
|
||||||
camelMaxHealthMax = getDouble("mobs.camel.attributes.max_health.max", camelMaxHealthMax);
|
camelMaxHealthMax = getDouble("mobs.camel.attributes.max_health.max", camelMaxHealthMax);
|
||||||
@@ -1744,7 +1756,15 @@ public class PurpurWorldConfig {
|
@@ -1764,7 +1776,15 @@ public class PurpurWorldConfig {
|
||||||
public boolean frogControllable = true;
|
public boolean frogControllable = true;
|
||||||
public float frogRidableJumpHeight = 0.65F;
|
public float frogRidableJumpHeight = 0.65F;
|
||||||
public int frogBreedingTicks = 6000;
|
public int frogBreedingTicks = 6000;
|
||||||
@@ -258,7 +256,7 @@ index 1ff95cced..0318c4916 100644
|
|||||||
frogRidable = getBoolean("mobs.frog.ridable", frogRidable);
|
frogRidable = getBoolean("mobs.frog.ridable", frogRidable);
|
||||||
frogRidableInWater = getBoolean("mobs.frog.ridable-in-water", frogRidableInWater);
|
frogRidableInWater = getBoolean("mobs.frog.ridable-in-water", frogRidableInWater);
|
||||||
frogControllable = getBoolean("mobs.frog.controllable", frogControllable);
|
frogControllable = getBoolean("mobs.frog.controllable", frogControllable);
|
||||||
@@ -2756,7 +2776,13 @@ public class PurpurWorldConfig {
|
@@ -2776,7 +2796,13 @@ public class PurpurWorldConfig {
|
||||||
public double snifferMaxHealth = 14.0D;
|
public double snifferMaxHealth = 14.0D;
|
||||||
public double snifferScale = 1.0D;
|
public double snifferScale = 1.0D;
|
||||||
public int snifferBreedingTicks = 6000;
|
public int snifferBreedingTicks = 6000;
|
||||||
@@ -272,7 +270,7 @@ index 1ff95cced..0318c4916 100644
|
|||||||
snifferRidable = getBoolean("mobs.sniffer.ridable", snifferRidable);
|
snifferRidable = getBoolean("mobs.sniffer.ridable", snifferRidable);
|
||||||
snifferRidableInWater = getBoolean("mobs.sniffer.ridable-in-water", snifferRidableInWater);
|
snifferRidableInWater = getBoolean("mobs.sniffer.ridable-in-water", snifferRidableInWater);
|
||||||
snifferControllable = getBoolean("mobs.sniffer.controllable", snifferControllable);
|
snifferControllable = getBoolean("mobs.sniffer.controllable", snifferControllable);
|
||||||
@@ -2864,7 +2890,15 @@ public class PurpurWorldConfig {
|
@@ -2884,7 +2910,15 @@ public class PurpurWorldConfig {
|
||||||
public boolean tadpoleRidable = false;
|
public boolean tadpoleRidable = false;
|
||||||
public boolean tadpoleRidableInWater = true;
|
public boolean tadpoleRidableInWater = true;
|
||||||
public boolean tadpoleControllable = true;
|
public boolean tadpoleControllable = true;
|
||||||
@@ -288,7 +286,7 @@ index 1ff95cced..0318c4916 100644
|
|||||||
tadpoleRidable = getBoolean("mobs.tadpole.ridable", tadpoleRidable);
|
tadpoleRidable = getBoolean("mobs.tadpole.ridable", tadpoleRidable);
|
||||||
tadpoleRidableInWater = getBoolean("mobs.tadpole.ridable-in-water", tadpoleRidableInWater);
|
tadpoleRidableInWater = getBoolean("mobs.tadpole.ridable-in-water", tadpoleRidableInWater);
|
||||||
tadpoleControllable = getBoolean("mobs.tadpole.controllable", tadpoleControllable);
|
tadpoleControllable = getBoolean("mobs.tadpole.controllable", tadpoleControllable);
|
||||||
@@ -3092,7 +3126,15 @@ public class PurpurWorldConfig {
|
@@ -3116,7 +3150,15 @@ public class PurpurWorldConfig {
|
||||||
public boolean wardenRidable = false;
|
public boolean wardenRidable = false;
|
||||||
public boolean wardenRidableInWater = true;
|
public boolean wardenRidableInWater = true;
|
||||||
public boolean wardenControllable = true;
|
public boolean wardenControllable = true;
|
||||||
@@ -1,319 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Wed, 27 Sep 2023 21:18:22 +0900
|
|
||||||
Subject: [PATCH] Reduce create random instance
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
index c63910d9215875e91968c509932b9f5393bb6457..c921595420939847bf91dc0cbb07faf3d815b02f 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
@@ -238,6 +238,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
@Nullable
|
|
||||||
private ServerStatus.Favicon statusIcon;
|
|
||||||
private final RandomSource random;
|
|
||||||
+ public static RandomSource random() { return getServer().random; } // Plazma - Expose random
|
|
||||||
public final DataFixer fixerUpper;
|
|
||||||
private String localIp;
|
|
||||||
private int port;
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
|
|
||||||
index b47a8a082170bcb630c4354be7c77a4cac71d105..7fe6b99e146e7374cd29534f1e89046edd340a82 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
|
|
||||||
@@ -66,7 +66,7 @@ public class SpreadPlayersCommand {
|
|
||||||
if (maxY < j) {
|
|
||||||
throw SpreadPlayersCommand.ERROR_INVALID_MAX_HEIGHT.create(maxY, j);
|
|
||||||
} else {
|
|
||||||
- RandomSource randomsource = RandomSource.create();
|
|
||||||
+ RandomSource randomsource = worldserver.plazmaConfig().misc.reduceRandom ? worldserver.getRandom() : RandomSource.create(); // Plazma - Reduce create random instance
|
|
||||||
double d0 = (double) (center.x - maxRange);
|
|
||||||
double d1 = (double) (center.y - maxRange);
|
|
||||||
double d2 = (double) (center.x + maxRange);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
||||||
index 4f72ce384f4c0dbae98effa89aed5c3bb802e635..dfb058756662886c13fb95009d454ecb12fa9b9b 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
||||||
@@ -469,7 +469,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
|
||||||
long l = k * k;
|
|
||||||
int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l;
|
|
||||||
int j1 = this.getCoprime(i1);
|
|
||||||
- int k1 = RandomSource.create().nextInt(i1);
|
|
||||||
+ int k1 = (worldserver.plazmaConfig().misc.reduceRandom ? worldserver.getRandom() : RandomSource.create()).nextInt(i1); // Plazma - Reduce create random instance
|
|
||||||
|
|
||||||
for (int l1 = 0; l1 < i1; ++l1) {
|
|
||||||
int i2 = (k1 + j1 * l1) % i1;
|
|
||||||
@@ -508,7 +508,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
|
||||||
long l = k * k;
|
|
||||||
int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l;
|
|
||||||
int j1 = this.getCoprime(i1);
|
|
||||||
- int k1 = RandomSource.create().nextInt(i1);
|
|
||||||
+ int k1 = (world.plazmaConfig().misc.reduceRandom ? world.getRandom() : RandomSource.create()).nextInt(i1); // Plazma - Reduce create random instance
|
|
||||||
|
|
||||||
for (int l1 = 0; l1 < i1; ++l1) {
|
|
||||||
int i2 = (k1 + j1 * l1) % i1;
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
||||||
index 19d3423644a6a394743c09eb6935bb7633a329a2..7c24e43b795b1483d9c1ff71b8fa254f88ae06c9 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
||||||
@@ -98,7 +98,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
|
||||||
this.serverId = "";
|
|
||||||
this.server = server;
|
|
||||||
this.connection = connection;
|
|
||||||
- this.challenge = Ints.toByteArray(RandomSource.create().nextInt());
|
|
||||||
+ this.challenge = Ints.toByteArray((org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? MinecraftServer.random() : RandomSource.create()).nextInt()); // Plazma - Reduce create random instance
|
|
||||||
this.transferred = transferred;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
|
|
||||||
index 0e0867d7add9a024bbe9471f8ff92bbb25996a3d..c0fad810538ede0f248898db2e68625b96e56c16 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
|
|
||||||
@@ -341,7 +341,7 @@ public class QueryThreadGs4 extends GenericThread {
|
|
||||||
this.identBytes[2] = bs[5];
|
|
||||||
this.identBytes[3] = bs[6];
|
|
||||||
this.ident = new String(this.identBytes, StandardCharsets.UTF_8);
|
|
||||||
- this.challenge = RandomSource.create().nextInt(16777216);
|
|
||||||
+ this.challenge = (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? net.minecraft.server.MinecraftServer.random() : RandomSource.create()).nextInt(16777216); // Plazma - Reduce create random instance
|
|
||||||
this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
|
||||||
index 3fac11bf02652b5f51f30f99bdf516504467d0d2..9d939624756e8a7a07a787f9807f095c5033b234 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
|
||||||
@@ -15,7 +15,7 @@ import net.minecraft.util.RandomSource;
|
|
||||||
|
|
||||||
public class ShufflingList<U> implements Iterable<U> {
|
|
||||||
protected final List<ShufflingList.WeightedEntry<U>> entries;
|
|
||||||
- private final RandomSource random = RandomSource.create();
|
|
||||||
+ private final RandomSource random = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? net.minecraft.server.MinecraftServer.random() : RandomSource.create(); // Plazma - Reduce create random instance
|
|
||||||
private final boolean isUnsafe; // Paper - Fix Concurrency issue in ShufflingList during worldgen
|
|
||||||
|
|
||||||
public ShufflingList() {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
|
||||||
index 09a7b418ddf564c0be13297f7c216db2e7ae1578..703006eb5df8099c4f51cdb4e41f95cacfbe43a6 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
|
||||||
@@ -8,7 +8,7 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
|
||||||
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
|
|
||||||
|
|
||||||
public abstract class Sensor<E extends LivingEntity> {
|
|
||||||
- private static final RandomSource RANDOM = RandomSource.createThreadSafe();
|
|
||||||
+ private static final RandomSource RANDOM = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom && org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.ignoreThreadSafeRandom ? net.minecraft.server.MinecraftServer.random() : RandomSource.createThreadSafe(); // Plazma - Reduce create random instance
|
|
||||||
private static final int DEFAULT_SCAN_RATE = 20;
|
|
||||||
protected static final int TARGETING_RANGE = 16;
|
|
||||||
private static final TargetingConditions TARGET_CONDITIONS = TargetingConditions.forNonCombat().range(16.0);
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java b/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java
|
|
||||||
index 3d792957f27fd4bdfad8d76262a8e2a2012bf35f..71539b5910692489cad6f78ac90f3aabc4e58236 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java
|
|
||||||
@@ -33,7 +33,7 @@ public class AngerManagement {
|
|
||||||
@VisibleForTesting
|
|
||||||
protected static final int MAX_ANGER = 150;
|
|
||||||
private static final int DEFAULT_ANGER_DECREASE = 1;
|
|
||||||
- private int conversionDelay = Mth.randomBetweenInclusive(RandomSource.create(), 0, 2);
|
|
||||||
+ private int conversionDelay = Mth.randomBetweenInclusive((org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? net.minecraft.server.MinecraftServer.random() : RandomSource.create()), 0, 2); // Plazma - Reduce create random instance
|
|
||||||
int highestAnger;
|
|
||||||
private static final Codec<Pair<UUID, Integer>> SUSPECT_ANGER_PAIR = RecordCodecBuilder.create(
|
|
||||||
instance -> instance.group(
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
|
||||||
index 96e9fce5f9084737d2fcf4deb83305733b480179..43da8ea227b2b01d6975a3f4f209099d350386f6 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
|
||||||
@@ -32,7 +32,7 @@ public class WanderingTraderSpawner implements CustomSpawner {
|
|
||||||
private static final int SPAWN_CHANCE_INCREASE = 25;
|
|
||||||
private static final int SPAWN_ONE_IN_X_CHANCE = 10;
|
|
||||||
private static final int NUMBER_OF_SPAWN_ATTEMPTS = 10;
|
|
||||||
- private final RandomSource random = RandomSource.create();
|
|
||||||
+ private final RandomSource random = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? net.minecraft.server.MinecraftServer.random() : RandomSource.create(); // Plazma - reduce create random instace
|
|
||||||
private final ServerLevelData serverLevelData;
|
|
||||||
private int tickDelay;
|
|
||||||
private int spawnDelay;
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
|
||||||
index 1223c5d23d0ea6aed068bdf0f5725e2ad49fc82c..0475c451fde5c8d370c1bc6fe6d27fa7bca287d1 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
|
||||||
@@ -88,7 +88,7 @@ public class FishingHook extends Projectile {
|
|
||||||
|
|
||||||
private FishingHook(EntityType<? extends FishingHook> type, Level world, int luckBonus, int waitTimeReductionTicks) {
|
|
||||||
super(type, world);
|
|
||||||
- this.syncronizedRandom = RandomSource.create();
|
|
||||||
+ this.syncronizedRandom = world.plazmaConfig().misc.reduceRandom ? world.getRandom() : RandomSource.create(); // Plazma - Reduce create random instance
|
|
||||||
this.openWater = true;
|
|
||||||
this.currentState = FishingHook.FishHookState.FLYING;
|
|
||||||
this.noCulling = true;
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
||||||
index dcbef04bbaab988096bf416163264833e84d1967..ea3dd26a6c357b41f33cad1b2953d356587d8759 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
||||||
@@ -115,7 +115,7 @@ public class Raid {
|
|
||||||
|
|
||||||
public Raid(int id, ServerLevel world, BlockPos pos) {
|
|
||||||
this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10);
|
|
||||||
- this.random = RandomSource.create();
|
|
||||||
+ this.random = world.plazmaConfig().misc.reduceRandom ? world.getRandom() : RandomSource.create(); // Plazma - Reduce create random instace
|
|
||||||
this.waveSpawnPos = Optional.empty();
|
|
||||||
this.id = id;
|
|
||||||
this.level = world;
|
|
||||||
@@ -129,7 +129,7 @@ public class Raid {
|
|
||||||
|
|
||||||
public Raid(ServerLevel world, CompoundTag nbt) {
|
|
||||||
this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10);
|
|
||||||
- this.random = RandomSource.create();
|
|
||||||
+ this.random = world.plazmaConfig().misc.reduceRandom ? world.getRandom() : RandomSource.create(); // Plazma - Reduce create random instace
|
|
||||||
this.waveSpawnPos = Optional.empty();
|
|
||||||
this.level = world;
|
|
||||||
this.id = nbt.getInt("Id");
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
|
|
||||||
index e59a38d051179753fa9b29e8d746e25e162cac3e..a4b9c9d5a7af9cbe8786e9c9a071968aa5b42c2f 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
|
|
||||||
@@ -99,7 +99,7 @@ public class EnchantmentMenu extends AbstractContainerMenu {
|
|
||||||
}
|
|
||||||
// Purpur end
|
|
||||||
};
|
|
||||||
- this.random = RandomSource.create();
|
|
||||||
+ this.random = playerInventory.player.level().plazmaConfig().misc.reduceRandom ? playerInventory.player.level().random : RandomSource.create(); // Plazma - Reduce create random instace
|
|
||||||
this.enchantmentSeed = DataSlot.standalone();
|
|
||||||
this.costs = new int[3];
|
|
||||||
this.enchantClue = new int[]{-1, -1, -1};
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
||||||
index 4ea1ce1cface25b9bf0e3958d55ba2fbbff69a9e..20f4d2a0996f3eb56bae5116b63b99a3a87e79b5 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
||||||
@@ -336,7 +336,7 @@ public class Explosion {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Explosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particle, ParticleOptions emitterParticle, Holder<SoundEvent> soundEvent) {
|
|
||||||
- this.random = RandomSource.create();
|
|
||||||
+ this.random = world.plazmaConfig().misc.reduceRandom ? world.getRandom() : RandomSource.create(); // Plazma - Reduce create random instace
|
|
||||||
this.toBlow = new ObjectArrayList();
|
|
||||||
this.hitPlayers = Maps.newHashMap();
|
|
||||||
this.level = world;
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
index f3c44a2ddc52661984cc07b2ee23b3a3431a4b0a..9ab004fa35687ca3274f7b937e5c379e93353c35 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
@@ -123,16 +123,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
||||||
public final Thread thread;
|
|
||||||
private final boolean isDebug;
|
|
||||||
private int skyDarken;
|
|
||||||
- protected int randValue = RandomSource.create().nextInt();
|
|
||||||
protected final int addend = 1013904223;
|
|
||||||
protected float oRainLevel;
|
|
||||||
public float rainLevel;
|
|
||||||
protected float oThunderLevel;
|
|
||||||
public float thunderLevel;
|
|
||||||
public final RandomSource random = RandomSource.create();
|
|
||||||
+ protected int randValue = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? random.nextInt() : RandomSource.create().nextInt(); // Plazma - Reduce create random instace
|
|
||||||
/** @deprecated */
|
|
||||||
@Deprecated
|
|
||||||
- private final RandomSource threadSafeRandom = RandomSource.createThreadSafe();
|
|
||||||
+ private final RandomSource threadSafeRandom = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.ignoreThreadSafeRandom ? random : RandomSource.createThreadSafe(); // Plazma - Reduce create random instace
|
|
||||||
private final Holder<DimensionType> dimensionTypeRegistration;
|
|
||||||
public final WritableLevelData levelData;
|
|
||||||
private final Supplier<ProfilerFiller> profiler;
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
||||||
index 89df488afeffd0c060d2d0e7fae16daf978bd192..743223bacd9db48a1afb6896e7e27560eb4c39f7 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
||||||
@@ -268,7 +268,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void spawnGatewayPortal(ServerLevel world, BlockPos pos, EndGatewayConfiguration config) {
|
|
||||||
- Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), RandomSource.create(), pos);
|
|
||||||
+ Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), (world.plazmaConfig().misc.reduceRandom ? world.getRandom() : RandomSource.create()), pos); // Plazma - Reduce create random instance
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
||||||
index a6b6e5ea191c0e2cd7a2e4f01b89d8af40a83c1b..19769ac9fa688969fd2db7c9a5e92eaadac124c4 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
||||||
@@ -224,7 +224,7 @@ public class ChunkGeneratorStructureState {
|
|
||||||
List<CompletableFuture<ChunkPos>> list = new ArrayList(j);
|
|
||||||
int k = placement.spread();
|
|
||||||
HolderSet<Biome> holderset = placement.preferredBiomes();
|
|
||||||
- RandomSource randomsource = RandomSource.create();
|
|
||||||
+ RandomSource randomsource = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? net.minecraft.server.MinecraftServer.random() : RandomSource.create(); // Plazma - Reduce create random instace
|
|
||||||
|
|
||||||
// Paper start - Add missing structure set seed configs
|
|
||||||
if (this.conf.strongholdSeed != null && structureSetEntry.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java b/src/main/java/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java
|
|
||||||
index 7bbe93966fa00b7001da53bf2f22f4d942b7cc22..6c5eececc83571b0f60e7f672ed185e1d262e99c 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java
|
|
||||||
@@ -81,7 +81,7 @@ public enum DragonRespawnAnimation {
|
|
||||||
world.explode((Entity) null, (double) ((float) worldgenender_spike.getCenterX() + 0.5F), (double) worldgenender_spike.getHeight(), (double) ((float) worldgenender_spike.getCenterZ() + 0.5F), 5.0F, Level.ExplosionInteraction.BLOCK);
|
|
||||||
SpikeConfiguration worldgenfeatureendspikeconfiguration = new SpikeConfiguration(true, ImmutableList.of(worldgenender_spike), new BlockPos(0, 128, 0));
|
|
||||||
|
|
||||||
- Feature.END_SPIKE.place(worldgenfeatureendspikeconfiguration, world, world.getChunkSource().getGenerator(), RandomSource.create(), new BlockPos(worldgenender_spike.getCenterX(), 45, worldgenender_spike.getCenterZ()));
|
|
||||||
+ Feature.END_SPIKE.place(worldgenfeatureendspikeconfiguration, world, world.getChunkSource().getGenerator(), (world.plazmaConfig().misc.reduceRandom ? world.getRandom() : RandomSource.create()), new BlockPos(worldgenender_spike.getCenterX(), 45, worldgenender_spike.getCenterZ())); // Plazma - Reduce create random instance
|
|
||||||
}
|
|
||||||
} else if (flag1) {
|
|
||||||
fight.setRespawnStage(SUMMONING_DRAGON); // CraftBukkit - decompile error
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
||||||
index 84300f2f7b7be4f5281edd8e263646dbcbb3ba07..3678c0f583becdec5baa292f81a5eff5663786bd 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
||||||
@@ -474,7 +474,7 @@ public class EndDragonFight {
|
|
||||||
this.level.registryAccess().registry(Registries.CONFIGURED_FEATURE).flatMap((iregistry) -> {
|
|
||||||
return iregistry.getHolder(EndFeatures.END_GATEWAY_DELAYED);
|
|
||||||
}).ifPresent((holder_c) -> {
|
|
||||||
- ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), pos);
|
|
||||||
+ holder_c.value().place(this.level, this.level.getChunkSource().getGenerator(), (this.level.plazmaConfig().misc.reduceRandom ? this.level.getRandom() : RandomSource.create()), pos); // Plazma - Reduce create random instace
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ public class EndDragonFight {
|
|
||||||
this.portalLocation = this.portalLocation.atY(this.level.getMinBuildHeight() + 1);
|
|
||||||
}
|
|
||||||
// Paper end - Prevent "softlocked" exit portal generation
|
|
||||||
- if (worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation)) {
|
|
||||||
+ if (worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), (this.level.plazmaConfig().misc.reduceRandom ? this.level.getRandom() : RandomSource.create()), this.portalLocation)) { // Plazma - Reduce create random instace
|
|
||||||
int i = Mth.positiveCeilDiv(4, 16);
|
|
||||||
|
|
||||||
this.level.getChunkSource().chunkMap.waitForLightBeforeSending(new ChunkPos(this.portalLocation), i);
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
|
||||||
index 759b6e54db93792c9862b1f1625118ac6fa49d7a..2dccc06d847af695806321b303b6d7cab89bcb7f 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
|
||||||
@@ -14,11 +14,12 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
|
||||||
|
|
||||||
public class CraftFirework extends CraftProjectile implements Firework {
|
|
||||||
|
|
||||||
- private final Random random = new Random();
|
|
||||||
+ private final net.minecraft.util.RandomSource random; // Plazma - Reduce create random instance
|
|
||||||
//private CraftItemStack item; // Paper - Remove usage, not accurate representation of current item.
|
|
||||||
|
|
||||||
public CraftFirework(CraftServer server, FireworkRocketEntity entity) {
|
|
||||||
super(server, entity);
|
|
||||||
+ this.random = this.getHandle().level().plazmaConfig().misc.reduceRandom ? this.getHandle().level().getRandom() : net.minecraft.util.RandomSource.create(); // Plazma - Reduce create random instance
|
|
||||||
|
|
||||||
// Paper start - Expose firework item directly
|
|
||||||
// ItemStack item = this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM);
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
index e725f6e8205976a7b137aefb98b874cf4ae14893..dad5379066140b1eadab0a283cc7d8c019d8f4b6 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
@@ -65,6 +65,8 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|
||||||
public Miscellaneous misc;
|
|
||||||
public class Miscellaneous extends ConfigurationPart {
|
|
||||||
|
|
||||||
+ public boolean reduceRandom = OPTIMIZE;
|
|
||||||
+ public boolean ignoreThreadSafeRandom = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
index b5b4229ccdecd63bd3e689e8247e44341d7c30cc..33544c734798d9fa1954c7806420f1e0b3653898 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
@@ -22,6 +22,7 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
||||||
public Miscellaneous misc;
|
|
||||||
public class Miscellaneous extends ConfigurationPart {
|
|
||||||
|
|
||||||
+ public boolean reduceRandom = OPTIMIZE;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Wed, 27 Sep 2023 22:11:15 +0900
|
|
||||||
Subject: [PATCH] Apply various optimizations
|
|
||||||
|
|
||||||
[REFERENCE PATCHES]
|
|
||||||
Akarin - Swaps the predicate order of collision
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
||||||
index 7aadcaa1785c6560eb1ce2f1179225facca47d84..2adc6f3400a2b914176d0ae0a85c479b00289fb4 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
||||||
@@ -2211,8 +2211,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
||||||
public void playerTouch(Player player) {}
|
|
||||||
|
|
||||||
public void push(Entity entity) {
|
|
||||||
+ if (entity.noPhysics || this.noPhysics) return; // Plazma - Swaps the predicate order of collision
|
|
||||||
if (!this.isPassengerOfSameVehicle(entity)) {
|
|
||||||
- if (!entity.noPhysics && !this.noPhysics) {
|
|
||||||
+ //if (!entity.noPhysics && !this.noPhysics) { // Plazma - Swaps the predicate order of collision
|
|
||||||
if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper - Collision option for requiring a player participant
|
|
||||||
double d0 = entity.getX() - this.getX();
|
|
||||||
double d1 = entity.getZ() - this.getZ();
|
|
||||||
@@ -2240,8 +2241,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
||||||
entity.push(d0, 0.0D, d1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- }
|
|
||||||
+ //} // Plazma - Swaps the predicate order of collision
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 5 Nov 2023 12:07:06 +0900
|
|
||||||
Subject: [PATCH] Do not load chunks to spawn phantom
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
|
||||||
index 04f67f7b43d2f461c776c76614dc3e5f060aea63..b3fe0dd152b3e2e1b83b4ec2270d387e6117ec1c 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
|
||||||
@@ -70,6 +70,7 @@ public class PhantomSpawner implements CustomSpawner {
|
|
||||||
|
|
||||||
if (randomsource.nextInt(j) >= world.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper - Ability to control player's insomnia and phantoms
|
|
||||||
BlockPos blockposition1 = blockposition.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21));
|
|
||||||
+ if (!world.plazmaConfig().entity.phantom.loadChunksToSpawn && !world.hasChunkAt(blockposition1)) continue; // Plazma - Do not load chunks to spawn phantom
|
|
||||||
BlockState iblockdata = world.getBlockState(blockposition1);
|
|
||||||
FluidState fluid = world.getFluidState(blockposition1);
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
index 33544c734798d9fa1954c7806420f1e0b3653898..b83a1058484e3d4d46f91d659f795f59d7087b72 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
@@ -32,6 +32,7 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
||||||
public Phantom phantom;
|
|
||||||
public class Phantom extends ConfigurationPart {
|
|
||||||
|
|
||||||
+ public boolean loadChunksToSpawn = !OPTIMIZE;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 5 Nov 2023 12:16:14 +0900
|
|
||||||
Subject: [PATCH] Add option to disable moved to quickly check for specific
|
|
||||||
players
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
index fd22a6709c7ffd828fbab5b8723f2b723af92f3d..79cfaf78840ac9052b83666d44cdd27f1ed3ae4f 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
@@ -1462,6 +1462,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
||||||
}
|
|
||||||
// Paper end - Prevent moving into unloaded chunks
|
|
||||||
|
|
||||||
+ if (!this.player.getBukkitEntity().hasPermission("plazma.bypass-moved-to-quickly-check") || !(org.plazmamc.plazma.configurations.GlobalConfiguration.get().player.checkSpectatorMovedToQuickly && this.player.isSpectator())) // Plazma - Options to bypass moved to quickly check
|
|
||||||
if (!this.player.isChangingDimension() && (!this.player.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !flag)) {
|
|
||||||
float f2 = flag ? 300.0F : 100.0F;
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
index dad5379066140b1eadab0a283cc7d8c019d8f4b6..b6c5fc90654a9d89d4c70948124be6ae66c86cdf 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
|
||||||
@@ -27,6 +27,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|
||||||
public Player player;
|
|
||||||
public class Player extends ConfigurationPart {
|
|
||||||
|
|
||||||
+ public boolean checkSpectatorMovedToQuickly = !OPTIMIZE;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Mon, 6 Nov 2023 11:36:08 +0900
|
|
||||||
Subject: [PATCH] Configurable entity sensor tick
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
||||||
index 4b4bdaf8c43e15ba953c160a003a719aaf730318..35f150d348c3bd27416c60840988d381b85f9ccf 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
||||||
@@ -953,10 +953,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
|
||||||
//ProfilerFiller gameprofilerfiller = this.level().getProfiler(); // Purpur
|
|
||||||
|
|
||||||
//gameprofilerfiller.push("sensing"); // Purpur
|
|
||||||
- this.sensing.tick();
|
|
||||||
+ //this.sensing.tick(); // Plazma - Moved down
|
|
||||||
//gameprofilerfiller.pop(); // Purpur
|
|
||||||
int i = this.tickCount + this.getId();
|
|
||||||
|
|
||||||
+ if (i % this.level().plazmaConfig().entity.sensorTick == 0) this.sensing.tick(); // Plazma - Configurable entity sensor tick
|
|
||||||
if (i % 2 != 0 && this.tickCount > 1) {
|
|
||||||
//gameprofilerfiller.push("targetSelector"); // Purpur
|
|
||||||
if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
index b83a1058484e3d4d46f91d659f795f59d7087b72..480f9948265bdb0742ebc4181bba564644809bff 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
||||||
@@ -29,6 +29,8 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
||||||
public Entity entity;
|
|
||||||
public class Entity extends ConfigurationPart {
|
|
||||||
|
|
||||||
+ public int sensorTick = 1;
|
|
||||||
+
|
|
||||||
public Phantom phantom;
|
|
||||||
public class Phantom extends ConfigurationPart {
|
|
||||||
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Mon, 4 Dec 2023 23:12:47 +0900
|
|
||||||
Subject: [PATCH] Optimise state lookup more
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java
|
|
||||||
index 57d0cd3ad6f972e986c72a57f1a6e36003f190c2..50d97c5ab33f33b81dbafd7cf42da5afd9856eeb 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java
|
|
||||||
@@ -17,6 +17,7 @@ public final class ZeroCollidingReferenceStateTable {
|
|
||||||
protected final StateHolder<?, ?> this_state;
|
|
||||||
|
|
||||||
protected long[] index_table;
|
|
||||||
+ public long[] index_table() { return this.index_table; } // Plazma - Getter
|
|
||||||
protected StateHolder<?, ?>[][] value_table;
|
|
||||||
|
|
||||||
public ZeroCollidingReferenceStateTable(final StateHolder<?, ?> state, final Map<Property<?>, Comparable<?>> this_map) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
|
|
||||||
index 45744d86e9582a93a0cec26009deea091080fbbe..5dd9473c55a08a775aa406901a0e54ef6f63837a 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
|
|
||||||
@@ -114,6 +114,12 @@ public abstract class StateHolder<O, S> {
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends Comparable<T>, V extends T> S trySetValue(Property<T> property, V value) {
|
|
||||||
+ // Plazma start - Optimise state lookup more
|
|
||||||
+ final S ret = (S) this.optimisedTable.get(property, value);
|
|
||||||
+ if (ret == null) throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value");
|
|
||||||
+ return ret;
|
|
||||||
+ /*
|
|
||||||
+ // Plazma end - Optimise state lookup more
|
|
||||||
Comparable<?> comparable = this.values.get(property);
|
|
||||||
if (comparable != null && !comparable.equals(value)) {
|
|
||||||
S object = this.neighbours.get(property, value);
|
|
||||||
@@ -125,10 +131,11 @@ public abstract class StateHolder<O, S> {
|
|
||||||
} else {
|
|
||||||
return (S)this;
|
|
||||||
}
|
|
||||||
+ */ // Plazma - Optimise state lookup more
|
|
||||||
}
|
|
||||||
|
|
||||||
public void populateNeighbours(Map<Map<Property<?>, Comparable<?>>, S> states) {
|
|
||||||
- if (this.neighbours != null) {
|
|
||||||
+ if (this.optimisedTable.index_table() != null) { // Plazma - optimise state lookup
|
|
||||||
throw new IllegalStateException();
|
|
||||||
} else {
|
|
||||||
Table<Property<?>, Comparable<?>, S> table = HashBasedTable.create();
|
|
||||||
@@ -143,7 +150,7 @@ public abstract class StateHolder<O, S> {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- this.neighbours = (Table<Property<?>, Comparable<?>, S>)(table.isEmpty() ? table : ArrayTable.create(table)); this.optimisedTable.loadInTable((Table)this.neighbours, this.values); // Paper - optimise state lookup
|
|
||||||
+ this.optimisedTable.loadInTable((Table) (table.isEmpty() ? table : ArrayTable.create(table)), this.values); // Plazma - Optimize state lookup more
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Wed, 10 Jan 2024 18:11:03 +0900
|
|
||||||
Subject: [PATCH] Improve SwingTime ticking
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
||||||
index f714e2dc212a3b70977e93c55e94f8b272c5b02d..0d48209efc607dd7f81deffa96af2ff05ccd37b7 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
||||||
@@ -2722,6 +2722,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateSwingTime() {
|
|
||||||
+ if (!this.swinging && this.swingTime == 0) return; // Plazma - Improve SwingTime ticking
|
|
||||||
int i = this.getCurrentSwingDuration();
|
|
||||||
|
|
||||||
if (this.swinging) {
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Sun, 5 May 2024 00:01:03 +0900
|
|
||||||
Subject: [PATCH] Add more MSPT
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/command/MSPTCommand.java b/src/main/java/io/papermc/paper/command/MSPTCommand.java
|
|
||||||
index 03be23690a94a14d7343526acad67ccf53b85c70..416c0a736edf47f76a37be0bc5fe8678cf89cdb3 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/command/MSPTCommand.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/command/MSPTCommand.java
|
|
||||||
@@ -45,8 +45,10 @@ public final class MSPTCommand extends Command {
|
|
||||||
MinecraftServer server = MinecraftServer.getServer();
|
|
||||||
|
|
||||||
List<Component> times = new ArrayList<>();
|
|
||||||
+ times.addAll(eval(server.tickTimes1s.getTimes())); // Plazma - Add more MSPT
|
|
||||||
times.addAll(eval(server.tickTimes5s.getTimes()));
|
|
||||||
times.addAll(eval(server.tickTimes10s.getTimes()));
|
|
||||||
+ times.addAll(eval(server.tickTimes30s.getTimes())); // Plazma - Add more MSPT
|
|
||||||
times.addAll(eval(server.tickTimes60s.getTimes()));
|
|
||||||
|
|
||||||
sender.sendMessage(text().content("Server tick times ").color(GOLD)
|
|
||||||
@@ -61,12 +63,18 @@ public final class MSPTCommand extends Command {
|
|
||||||
text(")")
|
|
||||||
)
|
|
||||||
).append(
|
|
||||||
- text(" from last 5s"),
|
|
||||||
+ // Plazma start - Add more MSPT
|
|
||||||
+ text(" from last 1s"),
|
|
||||||
+ text(",", GRAY),
|
|
||||||
+ text(" 5s"),
|
|
||||||
text(",", GRAY),
|
|
||||||
text(" 10s"),
|
|
||||||
text(",", GRAY),
|
|
||||||
+ text(" 30s"),
|
|
||||||
+ text(",", GRAY),
|
|
||||||
text(" 1m"),
|
|
||||||
text(":", YELLOW)
|
|
||||||
+ // Plazma end - Add more MSPT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
sender.sendMessage(text().content("◴ ").color(GOLD)
|
|
||||||
@@ -74,7 +82,11 @@ public final class MSPTCommand extends Command {
|
|
||||||
.append(
|
|
||||||
times.get(0), SLASH, times.get(1), SLASH, times.get(2), text(", ", YELLOW),
|
|
||||||
times.get(3), SLASH, times.get(4), SLASH, times.get(5), text(", ", YELLOW),
|
|
||||||
- times.get(6), SLASH, times.get(7), SLASH, times.get(8)
|
|
||||||
+ // Plazma start - Add more MSPT
|
|
||||||
+ times.get(6), SLASH, times.get(7), SLASH, times.get(8), text(", ", YELLOW),
|
|
||||||
+ times.get(9), SLASH, times.get(10), SLASH, times.get(11), text(", ", YELLOW),
|
|
||||||
+ times.get(12), SLASH, times.get(13), SLASH, times.get(14), text(", ", YELLOW)
|
|
||||||
+ // Plazma end - Add more MSPT
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
@@ -93,18 +105,26 @@ public final class MSPTCommand extends Command {
|
|
||||||
text(")")
|
|
||||||
)
|
|
||||||
).append(
|
|
||||||
- text(" from last 5s"),
|
|
||||||
+ // Plazma start - Add more MSPT
|
|
||||||
+ text(" from last 1s"),
|
|
||||||
+ text(",", GRAY),
|
|
||||||
+ text(" 5s"),
|
|
||||||
text(",", GRAY),
|
|
||||||
text(" 10s"),
|
|
||||||
text(",", GRAY),
|
|
||||||
+ text(" 30s"),
|
|
||||||
+ text(",", GRAY),
|
|
||||||
text(" 1m"),
|
|
||||||
text(":", YELLOW)
|
|
||||||
+ // Plazma end - Add more MSPT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
for (net.minecraft.server.level.ServerLevel level: server.getAllLevels()) {
|
|
||||||
List<Component> worldTimes = new ArrayList<>();
|
|
||||||
+ worldTimes.addAll(eval(level.tickTimes1s.getTimes())); // Plazma - Add more MSPT
|
|
||||||
worldTimes.addAll(eval(level.tickTimes5s.getTimes()));
|
|
||||||
worldTimes.addAll(eval(level.tickTimes10s.getTimes()));
|
|
||||||
+ worldTimes.addAll(eval(level.tickTimes30s.getTimes())); // Plazma - Add more MSPT
|
|
||||||
worldTimes.addAll(eval(level.tickTimes60s.getTimes()));
|
|
||||||
|
|
||||||
sender.sendMessage(text().content("◴ " + level.getWorld().getName() + ": ").color(GOLD)
|
|
||||||
@@ -112,7 +132,11 @@ public final class MSPTCommand extends Command {
|
|
||||||
.append(
|
|
||||||
worldTimes.get(0), SLASH, worldTimes.get(1), SLASH, worldTimes.get(2), text(", ", YELLOW),
|
|
||||||
worldTimes.get(3), SLASH, worldTimes.get(4), SLASH, worldTimes.get(5), text(", ", YELLOW),
|
|
||||||
- worldTimes.get(6), SLASH, worldTimes.get(7), SLASH, worldTimes.get(8)
|
|
||||||
+ // Plazma start - Add more MSPT
|
|
||||||
+ worldTimes.get(6), SLASH, worldTimes.get(7), SLASH, worldTimes.get(8), text(", ", YELLOW),
|
|
||||||
+ worldTimes.get(9), SLASH, worldTimes.get(10), SLASH, worldTimes.get(11), text(", ", YELLOW),
|
|
||||||
+ worldTimes.get(12), SLASH, worldTimes.get(13), SLASH, worldTimes.get(14), text(", ", YELLOW)
|
|
||||||
+ // Plazma end - Add more MSPT
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
index c921595420939847bf91dc0cbb07faf3d815b02f..565d601f16f054cc5aa7eb4040e1bd6586f62b7d 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
@@ -260,8 +260,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
private final long[] tickTimesNanos;
|
|
||||||
private long aggregatedTickTimesNanos;
|
|
||||||
// Paper start - Add tick times API and /mspt command
|
|
||||||
+ public final TickTimes tickTimes1s = new TickTimes(20); // Plazma - Add more MSPT
|
|
||||||
public final TickTimes tickTimes5s = new TickTimes(100);
|
|
||||||
public final TickTimes tickTimes10s = new TickTimes(200);
|
|
||||||
+ public final TickTimes tickTimes30s = new TickTimes(600); // Plazma - Add more MSPT
|
|
||||||
public final TickTimes tickTimes60s = new TickTimes(1200);
|
|
||||||
// Paper end - Add tick times API and /mspt command
|
|
||||||
@Nullable
|
|
||||||
@@ -1851,8 +1853,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
worldserver.tick(shouldKeepTicking); // diff on changes
|
|
||||||
long after = Util.getNanos() - before;
|
|
||||||
|
|
||||||
+ worldserver.tickTimes1s.add(this.tickCount, after); // Plazma - Add more MSPT
|
|
||||||
worldserver.tickTimes5s.add(this.tickCount, after);
|
|
||||||
worldserver.tickTimes10s.add(this.tickCount, after);
|
|
||||||
+ worldserver.tickTimes30s.add(this.tickCount, after); // Plazma - Add more MSPT
|
|
||||||
worldserver.tickTimes60s.add(this.tickCount, after);
|
|
||||||
// Plazma end - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
//worldserver.timings.doTick.stopTiming(); // Spigot // Purpur
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
index f5f944899d860d8363db43d430f3daab96e0d774..6fbf3a479ee1927b1099d2678db693341491b2b7 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
@@ -234,8 +234,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
|
||||||
public boolean hasRidableMoveEvent = false; // Purpur
|
|
||||||
|
|
||||||
// Plazma start - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
+ public final MinecraftServer.TickTimes tickTimes1s = new MinecraftServer.TickTimes(20); // Plazma - Add more MSPT
|
|
||||||
public final MinecraftServer.TickTimes tickTimes5s = new MinecraftServer.TickTimes(100);
|
|
||||||
public final MinecraftServer.TickTimes tickTimes10s = new MinecraftServer.TickTimes(200);
|
|
||||||
+ public final MinecraftServer.TickTimes tickTimes30s = new MinecraftServer.TickTimes(600); // Plazma - Add more MSPT
|
|
||||||
public final MinecraftServer.TickTimes tickTimes60s = new MinecraftServer.TickTimes(1200);
|
|
||||||
// Plazma end - Port SparklyPaper patches; Track World specific MSPT
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Mon, 6 May 2024 12:25:59 +0900
|
|
||||||
Subject: [PATCH] Use Akair's flag when running the test server with gradle
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
||||||
index 3bb91f4d0447fc283c56ffab24cb8e203925ebad..5ce7a424cf6c307c52b406fbd981f5eca439fe2c 100644
|
|
||||||
--- a/build.gradle.kts
|
|
||||||
+++ b/build.gradle.kts
|
|
||||||
@@ -141,7 +141,7 @@ fun TaskContainer.registerRunTask(
|
|
||||||
languageVersion.set(JavaLanguageVersion.of(21))
|
|
||||||
vendor.set(JvmVendorSpec.JETBRAINS)
|
|
||||||
})
|
|
||||||
- jvmArgs("-XX:+AllowEnhancedClassRedefinition", "-XX:+AllowRedefinitionToAddDeleteMethods")
|
|
||||||
+ jvmArgs("-XX:+AllowEnhancedClassRedefinition", "-XX:+AllowRedefinitionToAddDeleteMethods", "-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled", "-XX:MaxGCPauseMillis=200", "-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC", "-XX:+AlwaysPreTouch", "-XX:G1HeapWastePercent=5", "-XX:G1MixedGCCountTarget=4", "-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90", "-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem", "-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs", "-Daikars.new.flags=true", "-XX:G1NewSizePercent=40", "-XX:G1MaxNewSizePercent=50", "-XX:G1HeapRegionSize=16M", "-XX:G1ReservePercent=15")
|
|
||||||
|
|
||||||
if (rootProject.childProjects["test-plugin"] != null) {
|
|
||||||
val testPluginJar = rootProject.project(":test-plugin").tasks.jar.flatMap { it.archiveFile }
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Mon, 6 May 2024 13:40:48 +0900
|
|
||||||
Subject: [PATCH] Use Plazma logo instead if server favicon doesn't exist
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
index 565d601f16f054cc5aa7eb4040e1bd6586f62b7d..6db6ba1adde3cd2d76055de12d780251623cb896 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
||||||
@@ -1588,29 +1588,32 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<ServerStatus.Favicon> loadStatusIcon() {
|
|
||||||
- Optional<Path> optional = Optional.of(this.getFile("server-icon.png")).filter((path) -> {
|
|
||||||
- return Files.isRegularFile(path, new LinkOption[0]);
|
|
||||||
- }).or(() -> {
|
|
||||||
- return this.storageSource.getIconFile().filter((path) -> {
|
|
||||||
- return Files.isRegularFile(path, new LinkOption[0]);
|
|
||||||
- });
|
|
||||||
- });
|
|
||||||
-
|
|
||||||
- return optional.flatMap((path) -> {
|
|
||||||
- try {
|
|
||||||
- BufferedImage bufferedimage = ImageIO.read(path.toFile());
|
|
||||||
-
|
|
||||||
- Preconditions.checkState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide");
|
|
||||||
- Preconditions.checkState(bufferedimage.getHeight() == 64, "Must be 64 pixels high");
|
|
||||||
- ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
|
|
||||||
-
|
|
||||||
- ImageIO.write(bufferedimage, "PNG", bytearrayoutputstream);
|
|
||||||
- return Optional.of(new ServerStatus.Favicon(bytearrayoutputstream.toByteArray()));
|
|
||||||
- } catch (Exception exception) {
|
|
||||||
- MinecraftServer.LOGGER.error("Couldn't load server icon", exception);
|
|
||||||
- return Optional.empty();
|
|
||||||
- }
|
|
||||||
- });
|
|
||||||
+ // Plazma start - Use Plazma logo instead if server favicon doesn't exist
|
|
||||||
+ @Nullable File file = Optional.of(this.getFile("server-icon.png").toPath()).filter(Files::isRegularFile)
|
|
||||||
+ .or(() -> this.storageSource.getIconFile().filter(Files::isRegularFile)).map(Path::toFile).orElse(null);
|
|
||||||
+ try (
|
|
||||||
+ java.io.InputStream stream = (file != null)
|
|
||||||
+ ? new java.io.FileInputStream(file)
|
|
||||||
+ : (
|
|
||||||
+ org.plazmamc.plazma.Options.VANILLA_ICO
|
|
||||||
+ ? null
|
|
||||||
+ : MinecraftServer.class.getResourceAsStream("logo.png")
|
|
||||||
+ )
|
|
||||||
+ ) {
|
|
||||||
+ if (stream == null) return Optional.empty();
|
|
||||||
+ if (file == null && !org.plazmamc.plazma.Options.VANILLA_ICO)
|
|
||||||
+ LOGGER.info("No server icon found, using the logo instead.");
|
|
||||||
+ BufferedImage bufferedimage = ImageIO.read(stream);
|
|
||||||
+ Preconditions.checkState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide");
|
|
||||||
+ Preconditions.checkState(bufferedimage.getHeight() == 64, "Must be 64 pixels high");
|
|
||||||
+ ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
|
|
||||||
+ ImageIO.write(bufferedimage, "PNG", bytearrayoutputstream);
|
|
||||||
+ return Optional.of(new ServerStatus.Favicon(bytearrayoutputstream.toByteArray()));
|
|
||||||
+ } catch (Exception exception) {
|
|
||||||
+ MinecraftServer.LOGGER.error("Couldn't load server icon", exception);
|
|
||||||
+ return Optional.empty();
|
|
||||||
+ }
|
|
||||||
+ // Plazma end - Use Plazma logo instead if server favicon doesn't exist
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Path> getWorldScreenshotFile() {
|
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/Options.java b/src/main/java/org/plazmamc/plazma/Options.java
|
|
||||||
index 3e0e67c089e269d0bccd4a0d2de5ac1ac515997e..2e75ca5d2b7d8f35814fe9a0814b19a9135d80cb 100644
|
|
||||||
--- a/src/main/java/org/plazmamc/plazma/Options.java
|
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/Options.java
|
|
||||||
@@ -8,5 +8,6 @@ public interface Options {
|
|
||||||
boolean AGGRESSIVE = Boolean.getBoolean("Plazma.aggressiveOptimize") && !NO_OPTIMIZE;
|
|
||||||
boolean VANILLAIZE = Boolean.getBoolean("Plazma.vanillaize") && !AGGRESSIVE;
|
|
||||||
boolean USE_VANILLA = Boolean.getBoolean("Plazma.useVanillaConfiguration") && !AGGRESSIVE && NO_OPTIMIZE;
|
|
||||||
+ boolean VANILLA_ICO = Boolean.getBoolean("Plazma.useVanillaFavicon");
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: AlphaKR93 <dev@alpha93.kr>
|
|
||||||
Date: Wed, 15 May 2024 14:30:55 +0900
|
|
||||||
Subject: [PATCH] Add some missing Pufferfish configurations
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
|
||||||
index 5b024bc6166a9034eeba729bf3a53236446a03de..d4d6e9f0d8bf15315412ce5193e45c147b047575 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
|
||||||
@@ -161,9 +161,11 @@ public class Armadillo extends Animal {
|
|
||||||
return ArmadilloAi.makeBrain(this.brainProvider().makeBrain(dynamic));
|
|
||||||
}
|
|
||||||
|
|
||||||
+ private int behaviorTick; // Plazma - Add missing pufferfish configurations
|
|
||||||
@Override
|
|
||||||
protected void customServerAiStep() {
|
|
||||||
//this.level().getProfiler().push("armadilloBrain"); // Purpur
|
|
||||||
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Plazma - Add missing pufferfish configurations
|
|
||||||
((Brain<Armadillo>) this.brain).tick((ServerLevel) this.level(), this); // CraftBukkit - decompile error
|
|
||||||
//this.level().getProfiler().pop(); // Purpur
|
|
||||||
//this.level().getProfiler().push("armadilloActivityUpdate"); // Purpur
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
|
||||||
index 00803dcc2d990046013b8a175af20359883a15fe..6781c9cda8118842e24712f335de6e5b817af82c 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
|
||||||
@@ -164,11 +164,12 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
|
|
||||||
return pose == Pose.SITTING ? Camel.SITTING_DIMENSIONS.scale(this.getAgeScale()) : super.getDefaultDimensions(pose);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ private int behaviorTick = 0; // Plazma - Add missing pufferfish configurations
|
|
||||||
@Override
|
|
||||||
protected void customServerAiStep() {
|
|
||||||
//this.level().getProfiler().push("camelBrain"); // Purpur
|
|
||||||
Brain<Camel> behaviorcontroller = (Brain<Camel>) this.getBrain(); // CraftBukkit - decompile error
|
|
||||||
-
|
|
||||||
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Plazma - Add missing pufferfish configurations
|
|
||||||
behaviorcontroller.tick((ServerLevel) this.level(), this);
|
|
||||||
//this.level().getProfiler().pop(); // Purpur
|
|
||||||
//this.level().getProfiler().push("camelActivityUpdate"); // Purpur
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
||||||
index bc931f54d1087f2515b8185368ade3e8dd55a00d..65ce4ccbb91ff87762da5f9ef53e6d069149abd8 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
||||||
@@ -515,9 +515,11 @@ public class Sniffer extends Animal {
|
|
||||||
return Brain.provider(SnifferAi.MEMORY_TYPES, SnifferAi.SENSOR_TYPES);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ private int behaviorTick; // Plazma - Add missing pufferfish configurations
|
|
||||||
@Override
|
|
||||||
protected void customServerAiStep() {
|
|
||||||
//this.level().getProfiler().push("snifferBrain"); // Purpur
|
|
||||||
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Plazma - Add missing pufferfish configurations
|
|
||||||
this.getBrain().tick((ServerLevel) this.level(), this);
|
|
||||||
//this.level().getProfiler().popPush("snifferActivityUpdate"); // Purpur
|
|
||||||
SnifferAi.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 78a5631753e5bdc16b786ac6951c8d39c4337767..7b1bf1449c2e1f1e2ea2a9f258624b128eb80918 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
|
|
||||||
@@ -320,7 +320,7 @@ public class Warden extends Monster implements VibrationSystem {
|
|
||||||
|
|
||||||
//worldserver.getProfiler().push("wardenBrain"); // Purpur
|
|
||||||
//if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - TODO: Move to Ridables patch
|
|
||||||
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
||||||
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Plazma - Add missing pufferfish configurations
|
|
||||||
this.getBrain().tick(worldserver, this);
|
|
||||||
//this.level().getProfiler().pop(); // Purpur
|
|
||||||
super.customServerAiStep();
|
|
||||||
@@ -8,11 +8,23 @@ Subject: [PATCH] Optimize default configurations
|
|||||||
- AkiraDevelopment/SimplyMC
|
- AkiraDevelopment/SimplyMC
|
||||||
- YouHaveTrouble/minecraft-exploits-and-how-to-fix-them
|
- YouHaveTrouble/minecraft-exploits-and-how-to-fix-them
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
|
index c867796f6..ecced2072 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
|
@@ -181,7 +222,7 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
|
@MergeMap
|
||||||
|
public Reference2IntMap<MobCategory> spawnLimits = Util.make(new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length), map -> Arrays.stream(NaturalSpawner.SPAWNING_CATEGORIES).forEach(mobCategory -> map.put(mobCategory, -1)));
|
||||||
|
@MergeMap
|
||||||
|
- public Map<MobCategory, DespawnRange> despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), category.getDespawnDistance())));
|
||||||
|
+ public Map<MobCategory, DespawnRange> despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize() ? (net.minecraft.server.MinecraftServer.getServer().server.getSimulationDistance() * 16) + 8 : category.getDespawnDistance()))); // Plazma - Optimize default configurations
|
||||||
|
@MergeMap
|
||||||
|
public Reference2IntMap<MobCategory> ticksPerSpawn = Util.make(new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length), map -> Arrays.stream(NaturalSpawner.SPAWNING_CATEGORIES).forEach(mobCategory -> map.put(mobCategory, -1)));
|
||||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
||||||
index 8f1645573..8e35f7fbe 100644
|
index 3ff4f092a59242a8cb930c084915a774db881652..66f797f5205b9b259cc6f6cfd710293fc73cdf59 100644
|
||||||
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
||||||
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
||||||
@@ -64,7 +64,7 @@ public class PufferfishConfig {
|
@@ -61,7 +61,7 @@ public class PufferfishConfig {
|
||||||
getString("info.version", "1.0");
|
getString("info.version", "1.0");
|
||||||
setComment("info",
|
setComment("info",
|
||||||
"Pufferfish Configuration",
|
"Pufferfish Configuration",
|
||||||
@@ -21,56 +33,35 @@ index 8f1645573..8e35f7fbe 100644
|
|||||||
"Join our Discord for support: https://discord.gg/reZw4vQV9H",
|
"Join our Discord for support: https://discord.gg/reZw4vQV9H",
|
||||||
"Download new builds at https://ci.pufferfish.host/job/Pufferfish");
|
"Download new builds at https://ci.pufferfish.host/job/Pufferfish");
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ public class PufferfishConfig {
|
@@ -216,7 +216,7 @@ public class PufferfishConfig {
|
||||||
public static int maxProjectileLoadsPerTick;
|
public static int maxProjectileLoadsPerTick;
|
||||||
public static int maxProjectileLoadsPerProjectile;
|
public static int maxProjectileLoadsPerProjectile;
|
||||||
private static void projectileLoading() {
|
private static void projectileLoading() {
|
||||||
- maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", 10, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick.");
|
- maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", 10, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick.");
|
||||||
+ maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize() ? 8 : 10, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick."); // Plazma - Optimize default configurations
|
+ maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", plazma.Config.optimize() ? 8 : 10, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick."); // Plazma - Optimize default configurations
|
||||||
maxProjectileLoadsPerProjectile = getInt("projectile.max-loads-per-projectile", 10, "Controls how many chunks a projectile", "can load in its lifetime before it gets", "automatically removed.");
|
maxProjectileLoadsPerProjectile = getInt("projectile.max-loads-per-projectile", 10, "Controls how many chunks a projectile", "can load in its lifetime before it gets", "automatically removed.");
|
||||||
|
|
||||||
setComment("projectile", "Optimizes projectile settings");
|
setComment("projectile", "Optimizes projectile settings");
|
||||||
@@ -233,12 +233,12 @@ public class PufferfishConfig {
|
@@ -230,12 +230,12 @@ public class PufferfishConfig {
|
||||||
public static int activationDistanceMod;
|
public static int activationDistanceMod;
|
||||||
|
|
||||||
private static void dynamicActivationOfBrains() throws IOException {
|
private static void dynamicActivationOfBrains() throws IOException {
|
||||||
- dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", false); // Purpur
|
- dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", false); // Purpur - Fix pufferfish issues
|
||||||
+ dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize()); // Purpur // Plazma - Optimize default configurations
|
+ dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", plazma.Config.optimize()); // Purpur - Fix pufferfish issues // Plazma - Optimize default configurations
|
||||||
startDistance = getInt("dab.start-distance", "activation-range.start-distance", 12,
|
startDistance = getInt("dab.start-distance", "activation-range.start-distance", 12,
|
||||||
"This value determines how far away an entity has to be",
|
"This value determines how far away an entity has to be",
|
||||||
"from the player to start being effected by DEAR.");
|
"from the player to start being effected by DEAR.");
|
||||||
startDistanceSquared = startDistance * startDistance;
|
startDistanceSquared = startDistance * startDistance;
|
||||||
- maximumActivationPrio = getInt("dab.max-tick-freq", "activation-range.max-tick-freq", 20,
|
- maximumActivationPrio = getInt("dab.max-tick-freq", "activation-range.max-tick-freq", 20,
|
||||||
+ maximumActivationPrio = getInt("dab.max-tick-freq", "activation-range.max-tick-freq", org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize() ? 7 : 8, // Plazma - Optimize default configurations
|
+ maximumActivationPrio = getInt("dab.max-tick-freq", "activation-range.max-tick-freq", plazma.Config.optimize() ? 7 : 8, // Plazma - Optimize default configurations
|
||||||
"This value defines how often in ticks, the furthest entity",
|
"This value defines how often in ticks, the furthest entity",
|
||||||
"will get their pathfinders and behaviors ticked. 20 = 1s");
|
"will get their pathfinders and behaviors ticked. 20 = 1s");
|
||||||
activationDistanceMod = getInt("dab.activation-dist-mod", "activation-range.activation-dist-mod", 8,
|
activationDistanceMod = getInt("dab.activation-dist-mod", "activation-range.activation-dist-mod", 8,
|
||||||
@@ -261,8 +261,18 @@ public class PufferfishConfig {
|
|
||||||
public static Map<String, Integer> projectileTimeouts;
|
|
||||||
private static void projectileTimeouts() {
|
|
||||||
// Set some defaults
|
|
||||||
- getInt("entity_timeouts.SNOWBALL", -1);
|
|
||||||
- getInt("entity_timeouts.LLAMA_SPIT", -1);
|
|
||||||
+ // Plazma start - Optimize default configurations
|
|
||||||
+ if (org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize()) {
|
|
||||||
+ getInt("entity_timeouts.ARROW", 200);
|
|
||||||
+ getInt("entity_timeouts.EGG", 200);
|
|
||||||
+ getInt("entity_timeouts.ENDER_PEARL", 200);
|
|
||||||
+ getInt("entity_timeouts.SNOWBALL", 200);
|
|
||||||
+ getInt("entity_timeouts.LLAMA_SPIT", 200);
|
|
||||||
+ } else {
|
|
||||||
+ getInt("entity_timeouts.SNOWBALL", -1);
|
|
||||||
+ getInt("entity_timeouts.LLAMA_SPIT", -1);
|
|
||||||
+ }
|
|
||||||
+ // Plazma end - Optimize default configurations
|
|
||||||
setComment("entity_timeouts",
|
|
||||||
"These values define a entity's maximum lifespan. If an",
|
|
||||||
"entity is in this list and it has survived for longer than",
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
index a9dd0e521..d417b773d 100644
|
index 088b8fe5d144807f4da1e85b2fa34dfd21286f8c..8c3c7987a269733a0f530e8f22c3f1a005de21ac 100644
|
||||||
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
@@ -172,7 +172,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
@@ -148,7 +148,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
public class Watchdog extends ConfigurationPart {
|
public class Watchdog extends ConfigurationPart {
|
||||||
public int earlyWarningEvery = 5000;
|
public int earlyWarningEvery = 5000;
|
||||||
@@ -79,7 +70,7 @@ index a9dd0e521..d417b773d 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SpamLimiter spamLimiter;
|
public SpamLimiter spamLimiter;
|
||||||
@@ -214,7 +214,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
@@ -188,7 +188,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
public Commands commands;
|
public Commands commands;
|
||||||
|
|
||||||
public class Commands extends ConfigurationPart {
|
public class Commands extends ConfigurationPart {
|
||||||
@@ -88,7 +79,7 @@ index a9dd0e521..d417b773d 100644
|
|||||||
public boolean fixTargetSelectorTagCompletion = true;
|
public boolean fixTargetSelectorTagCompletion = true;
|
||||||
public boolean timeCommandAffectsAllWorlds = false;
|
public boolean timeCommandAffectsAllWorlds = false;
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
@@ -253,7 +253,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
public BookSize bookSize;
|
public BookSize bookSize;
|
||||||
|
|
||||||
public class BookSize extends ConfigurationPart {
|
public class BookSize extends ConfigurationPart {
|
||||||
@@ -97,7 +88,7 @@ index a9dd0e521..d417b773d 100644
|
|||||||
public double totalMultiplier = 0.98D; // TODO this should probably be merged into the above inner class
|
public double totalMultiplier = 0.98D; // TODO this should probably be merged into the above inner class
|
||||||
}
|
}
|
||||||
public boolean resolveSelectorsInBooks = false;
|
public boolean resolveSelectorsInBooks = false;
|
||||||
@@ -274,7 +274,15 @@ public class GlobalConfiguration extends ConfigurationPart {
|
@@ -264,7 +264,15 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
public class PacketLimiter extends ConfigurationPart {
|
public class PacketLimiter extends ConfigurationPart {
|
||||||
public Component kickMessage = Component.translatable("disconnect.exceeded_packet_rate", NamedTextColor.RED);
|
public Component kickMessage = Component.translatable("disconnect.exceeded_packet_rate", NamedTextColor.RED);
|
||||||
public PacketLimit allPackets = new PacketLimit(7.0, 500.0, PacketLimit.ViolateAction.KICK);
|
public PacketLimit allPackets = new PacketLimit(7.0, 500.0, PacketLimit.ViolateAction.KICK);
|
||||||
@@ -114,7 +105,7 @@ index a9dd0e521..d417b773d 100644
|
|||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public record PacketLimit(@Required double interval, @Required double maxPacketRate, ViolateAction action) {
|
public record PacketLimit(@Required double interval, @Required double maxPacketRate, ViolateAction action) {
|
||||||
@@ -342,7 +350,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
@@ -332,7 +340,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
executor.setMaximumPoolSize(_chatExecutorMaxSize);
|
executor.setMaximumPoolSize(_chatExecutorMaxSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,10 +115,10 @@ index a9dd0e521..d417b773d 100644
|
|||||||
public boolean loadPermissionsYmlBeforePlugins = true;
|
public boolean loadPermissionsYmlBeforePlugins = true;
|
||||||
@Constraints.Min(4)
|
@Constraints.Min(4)
|
||||||
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
index c867796f6..ecced2072 100644
|
index 82210667376fd466d5d4cdcb56b62f6165bd5cde..3c6e9ec236bfd851700ce7fae2599b725ec899eb 100644
|
||||||
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
@@ -100,12 +100,32 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -103,12 +103,32 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
public class AntiXray extends ConfigurationPart {
|
public class AntiXray extends ConfigurationPart {
|
||||||
public boolean enabled = false;
|
public boolean enabled = false;
|
||||||
@@ -163,7 +154,7 @@ index c867796f6..ecced2072 100644
|
|||||||
//<editor-fold desc="Anti-Xray Hidden Blocks" defaultstate="collapsed">
|
//<editor-fold desc="Anti-Xray Hidden Blocks" defaultstate="collapsed">
|
||||||
Blocks.COPPER_ORE,
|
Blocks.COPPER_ORE,
|
||||||
Blocks.DEEPSLATE_COPPER_ORE,
|
Blocks.DEEPSLATE_COPPER_ORE,
|
||||||
@@ -132,7 +152,28 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -135,7 +155,28 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
Blocks.ENDER_CHEST
|
Blocks.ENDER_CHEST
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
);
|
);
|
||||||
@@ -193,7 +184,7 @@ index c867796f6..ecced2072 100644
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,14 +196,14 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -157,14 +198,14 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
public ArmorStands armorStands;
|
public ArmorStands armorStands;
|
||||||
|
|
||||||
public class ArmorStands extends ConfigurationPart {
|
public class ArmorStands extends ConfigurationPart {
|
||||||
@@ -211,7 +202,7 @@ index c867796f6..ecced2072 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Sniffer sniffer;
|
public Sniffer sniffer;
|
||||||
@@ -407,7 +448,7 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -415,7 +456,7 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
public class Environment extends ConfigurationPart {
|
public class Environment extends ConfigurationPart {
|
||||||
public boolean disableThunder = false;
|
public boolean disableThunder = false;
|
||||||
public boolean disableIceAndSnow = false;
|
public boolean disableIceAndSnow = false;
|
||||||
@@ -220,16 +211,16 @@ index c867796f6..ecced2072 100644
|
|||||||
public boolean disableExplosionKnockback = false;
|
public boolean disableExplosionKnockback = false;
|
||||||
public boolean generateFlatBedrock = false;
|
public boolean generateFlatBedrock = false;
|
||||||
public FrostedIce frostedIce;
|
public FrostedIce frostedIce;
|
||||||
@@ -463,7 +504,7 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -471,7 +512,7 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
public Fixes fixes;
|
public Fixes fixes;
|
||||||
|
|
||||||
public class Fixes extends ConfigurationPart {
|
public class Fixes extends ConfigurationPart {
|
||||||
- public boolean fixItemsMergingThroughWalls = false;
|
- public boolean fixItemsMergingThroughWalls = false;
|
||||||
+ public boolean fixItemsMergingThroughWalls = org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize(); // Plazma - Optimize default configurations
|
+ public boolean fixItemsMergingThroughWalls = org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize(); // Plazma - Optimize default configurations
|
||||||
public boolean disableUnloadedChunkEnderpearlExploit = true;
|
public boolean disableUnloadedChunkEnderpearlExploit = false;
|
||||||
public boolean preventTntFromMovingInWater = false;
|
public boolean preventTntFromMovingInWater = false;
|
||||||
public boolean splitOverstackedLoot = true;
|
public boolean splitOverstackedLoot = true;
|
||||||
@@ -491,9 +532,9 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -499,9 +540,9 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
public class Collisions extends ConfigurationPart {
|
public class Collisions extends ConfigurationPart {
|
||||||
public boolean onlyPlayersCollide = false;
|
public boolean onlyPlayersCollide = false;
|
||||||
public boolean allowVehicleCollisions = true;
|
public boolean allowVehicleCollisions = true;
|
||||||
@@ -241,7 +232,7 @@ index c867796f6..ecced2072 100644
|
|||||||
public boolean allowPlayerCrammingDamage = false;
|
public boolean allowPlayerCrammingDamage = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,18 +542,41 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -509,18 +550,41 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
public class Chunks extends ConfigurationPart {
|
public class Chunks extends ConfigurationPart {
|
||||||
public AutosavePeriod autoSaveInterval = AutosavePeriod.def();
|
public AutosavePeriod autoSaveInterval = AutosavePeriod.def();
|
||||||
@@ -291,7 +282,7 @@ index c867796f6..ecced2072 100644
|
|||||||
});
|
});
|
||||||
public boolean flushRegionsOnSave = false;
|
public boolean flushRegionsOnSave = false;
|
||||||
}
|
}
|
||||||
@@ -527,9 +591,9 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -535,9 +599,9 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
public TickRates tickRates;
|
public TickRates tickRates;
|
||||||
|
|
||||||
public class TickRates extends ConfigurationPart {
|
public class TickRates extends ConfigurationPart {
|
||||||
@@ -303,7 +294,7 @@ index c867796f6..ecced2072 100644
|
|||||||
public int wetFarmland = 1;
|
public int wetFarmland = 1;
|
||||||
public int dryFarmland = 1;
|
public int dryFarmland = 1;
|
||||||
public Table<EntityType<?>, String, Integer> sensor = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "secondarypoisensor", 40));
|
public Table<EntityType<?>, String, Integer> sensor = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "secondarypoisensor", 40));
|
||||||
@@ -563,9 +627,9 @@ public class WorldConfiguration extends ConfigurationPart {
|
@@ -571,9 +635,9 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
public class Misc extends ConfigurationPart {
|
public class Misc extends ConfigurationPart {
|
||||||
public int lightQueueSize = 20;
|
public int lightQueueSize = 20;
|
||||||
@@ -328,10 +319,10 @@ index 24763d3d270c29c95e0b3e85111145234f660a62..80ddc627e02e3c749e6b074afa93d357
|
|||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||||
index 639a0624f..e4b42f745 100644
|
index fc378b08c10c7f670be93d52937c7642b986ed0d..9a436132faa04efbf25d8be9d5488e13f2111dac 100644
|
||||||
--- a/src/main/java/net/minecraft/server/Main.java
|
--- a/src/main/java/net/minecraft/server/Main.java
|
||||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||||
@@ -152,7 +152,7 @@ public class Main {
|
@@ -166,7 +166,7 @@ public class Main {
|
||||||
File configFile = (File) optionset.valueOf("bukkit-settings");
|
File configFile = (File) optionset.valueOf("bukkit-settings");
|
||||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
|
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
|
||||||
configuration.options().copyDefaults(true);
|
configuration.options().copyDefaults(true);
|
||||||
@@ -341,7 +332,7 @@ index 639a0624f..e4b42f745 100644
|
|||||||
|
|
||||||
File commandFile = (File) optionset.valueOf("commands-settings");
|
File commandFile = (File) optionset.valueOf("commands-settings");
|
||||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
index 5971f99c0..ef0f1598f 100644
|
index 8f7e922ceca286b1a590181c301fbe9bff55c024..3dd5c7441bb300ca17d717af37edbefb89db4b2f 100644
|
||||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
@@ -132,14 +132,14 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
@@ -132,14 +132,14 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
@@ -373,10 +364,10 @@ index 5971f99c0..ef0f1598f 100644
|
|||||||
this.enableJmxMonitoring = this.get("enable-jmx-monitoring", false);
|
this.enableJmxMonitoring = this.get("enable-jmx-monitoring", false);
|
||||||
this.enableStatus = this.get("enable-status", true);
|
this.enableStatus = this.get("enable-status", true);
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index 0bd9f4dc2..52d9b6253 100644
|
index 090cb821a43ccfea21a990580e47b592df9d030f..4177a12d333925dd7f3422861847119f344a441b 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@@ -434,7 +434,7 @@ public final class CraftServer implements Server {
|
@@ -449,7 +449,7 @@ public final class CraftServer implements Server {
|
||||||
|
|
||||||
this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile());
|
this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile());
|
||||||
this.configuration.options().copyDefaults(true);
|
this.configuration.options().copyDefaults(true);
|
||||||
@@ -386,14 +377,14 @@ index 0bd9f4dc2..52d9b6253 100644
|
|||||||
if (!this.configuration.isString("aliases")) {
|
if (!this.configuration.isString("aliases")) {
|
||||||
legacyAlias = this.configuration.getConfigurationSection("aliases");
|
legacyAlias = this.configuration.getConfigurationSection("aliases");
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/Options.java b/src/main/java/org/plazmamc/plazma/Options.java
|
diff --git a/src/main/java/org/plazmamc/plazma/Options.java b/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
index 5942d0997f07bd51d934dac32cd349792a10643e..40a6ef72b4d495140c486c0880fdc5fc1a32931c 100644
|
index 5d41bd4d4b86ca0c7c03d3ac6e75b3f1f1abe73b..c608770ea0df26859a09b794e93292f4aa6881b4 100644
|
||||||
--- a/src/main/java/org/plazmamc/plazma/Options.java
|
--- a/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/Options.java
|
+++ b/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
@@ -5,5 +5,6 @@ import static java.lang.Boolean.getBoolean;
|
@@ -7,5 +7,6 @@ public interface Options {
|
||||||
public interface Options {
|
|
||||||
|
|
||||||
boolean NO_OPTIMIZE = getBoolean("Plazma.disableConfigOptimization");
|
boolean NO_OPTIMIZE = getBoolean("Plazma.disableConfigOptimization");
|
||||||
+ boolean AGGRESSIVE = Boolean.getBoolean("Plazma.aggressiveOptimize") && !NO_OPTIMIZE;
|
boolean NO_WARN = getBoolean("Plazma.iKnowWhatIAmDoing");
|
||||||
|
+ boolean AGGRESSIVE = getBoolean("Plazma.aggressiveOptimize") && !NO_OPTIMIZE;
|
||||||
|
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java
|
||||||
@@ -417,10 +408,10 @@ index 09053b4ccf268fd204c81dbb8d4f10fa9edcad5f..93f67f125b3674e645cfdae27e579e12
|
|||||||
#### ENGLISH ####
|
#### ENGLISH ####
|
||||||
This is the %s configuration file for Plazma.
|
This is the %s configuration file for Plazma.
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||||
index 546d92019..97fc4fb79 100644
|
index 7690441b5059ae6c7ca8519875ea8a515c5c5e93..f29059798c9dc642187b4939dd917ee15cbe120d 100644
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||||
@@ -243,7 +243,7 @@ public class PurpurConfig {
|
@@ -244,7 +244,7 @@ public class PurpurConfig {
|
||||||
laggingThreshold = getDouble("settings.lagging-threshold", laggingThreshold);
|
laggingThreshold = getDouble("settings.lagging-threshold", laggingThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +420,7 @@ index 546d92019..97fc4fb79 100644
|
|||||||
private static void useAlternateKeepAlive() {
|
private static void useAlternateKeepAlive() {
|
||||||
useAlternateKeepAlive = getBoolean("settings.use-alternate-keepalive", useAlternateKeepAlive);
|
useAlternateKeepAlive = getBoolean("settings.use-alternate-keepalive", useAlternateKeepAlive);
|
||||||
}
|
}
|
||||||
@@ -492,7 +492,7 @@ public class PurpurConfig {
|
@@ -491,7 +491,7 @@ public class PurpurConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean useUPnP = false;
|
public static boolean useUPnP = false;
|
||||||
@@ -439,10 +430,10 @@ index 546d92019..97fc4fb79 100644
|
|||||||
private static void networkSettings() {
|
private static void networkSettings() {
|
||||||
useUPnP = getBoolean("settings.network.upnp-port-forwarding", useUPnP);
|
useUPnP = getBoolean("settings.network.upnp-port-forwarding", useUPnP);
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||||
index 3bcbf5e2d..1ff95cced 100644
|
index 0d5a0e14cbaacc63eeced78a6c28cc64ad918522..43ad38dadfe14b3dd0565c536b276eb3f9dbd813 100644
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||||
@@ -424,7 +424,7 @@ public class PurpurWorldConfig {
|
@@ -426,7 +426,7 @@ public class PurpurWorldConfig {
|
||||||
public boolean idleTimeoutTargetPlayer = true;
|
public boolean idleTimeoutTargetPlayer = true;
|
||||||
public String playerDeathExpDropEquation = "expLevel * 7";
|
public String playerDeathExpDropEquation = "expLevel * 7";
|
||||||
public int playerDeathExpDropMax = 100;
|
public int playerDeathExpDropMax = 100;
|
||||||
@@ -451,7 +442,7 @@ index 3bcbf5e2d..1ff95cced 100644
|
|||||||
public boolean teleportOnNetherCeilingDamage = false;
|
public boolean teleportOnNetherCeilingDamage = false;
|
||||||
public boolean totemOfUndyingWorksInInventory = false;
|
public boolean totemOfUndyingWorksInInventory = false;
|
||||||
public boolean playerFixStuckPortal = false;
|
public boolean playerFixStuckPortal = false;
|
||||||
@@ -3247,7 +3247,7 @@ public class PurpurWorldConfig {
|
@@ -3271,7 +3271,7 @@ public class PurpurWorldConfig {
|
||||||
public boolean zombieJockeyOnlyBaby = true;
|
public boolean zombieJockeyOnlyBaby = true;
|
||||||
public double zombieJockeyChance = 0.05D;
|
public double zombieJockeyChance = 0.05D;
|
||||||
public boolean zombieJockeyTryExistingChickens = true;
|
public boolean zombieJockeyTryExistingChickens = true;
|
||||||
@@ -461,7 +452,7 @@ index 3bcbf5e2d..1ff95cced 100644
|
|||||||
public boolean zombieTakeDamageFromWater = false;
|
public boolean zombieTakeDamageFromWater = false;
|
||||||
public boolean zombieAlwaysDropExp = false;
|
public boolean zombieAlwaysDropExp = false;
|
||||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||||
index 2c408fa4a..aadad0a1e 100644
|
index 2c408fa4abcbe1171c58aee8799c8cf7867d0f0a..aadad0a1e3c7e20b0ab97095ee6e6fb7dbfbd234 100644
|
||||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||||
@@ -150,14 +150,14 @@ public class SpigotWorldConfig
|
@@ -150,14 +150,14 @@ public class SpigotWorldConfig
|
||||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Add an option to apply the configuration to the vanilla
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
index d417b773dec5f2c4a8e115864338612d8e4b9f6c..f89ae1a542120eb01c028a1a1f0771ac211bcd49 100644
|
index 8c3c7987a269733a0f530e8f22c3f1a005de21ac..20def77109eb9cd98a7677e73b4316544be86283 100644
|
||||||
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||||
@@ -89,7 +89,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
@@ -88,7 +88,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
public Component flyingVehicle = Component.translatable("multiplayer.disconnect.flying");
|
public Component flyingVehicle = Component.translatable("multiplayer.disconnect.flying");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,10 +19,10 @@ index d417b773dec5f2c4a8e115864338612d8e4b9f6c..f89ae1a542120eb01c028a1a1f0771ac
|
|||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index 52d9b6253e05cae57d44f340b33316eff113db2e..47cbac24d704a047f56a98c9eb0f8a8b2001ae48 100644
|
index 4177a12d333925dd7f3422861847119f344a441b..15527e902484496a6804c879d1de589bed3f8713 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@@ -434,7 +434,19 @@ public final class CraftServer implements Server {
|
@@ -449,7 +449,19 @@ public final class CraftServer implements Server {
|
||||||
|
|
||||||
this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile());
|
this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile());
|
||||||
this.configuration.options().copyDefaults(true);
|
this.configuration.options().copyDefaults(true);
|
||||||
@@ -44,15 +44,15 @@ index 52d9b6253e05cae57d44f340b33316eff113db2e..47cbac24d704a047f56a98c9eb0f8a8b
|
|||||||
if (!this.configuration.isString("aliases")) {
|
if (!this.configuration.isString("aliases")) {
|
||||||
legacyAlias = this.configuration.getConfigurationSection("aliases");
|
legacyAlias = this.configuration.getConfigurationSection("aliases");
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/Options.java b/src/main/java/org/plazmamc/plazma/Options.java
|
diff --git a/src/main/java/org/plazmamc/plazma/Options.java b/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
index 40a6ef72b4d495140c486c0880fdc5fc1a32931c..3e0e67c089e269d0bccd4a0d2de5ac1ac515997e 100644
|
index c608770ea0df26859a09b794e93292f4aa6881b4..063b71b3043a69a90130a81686b6a5f1e5f22fd1 100644
|
||||||
--- a/src/main/java/org/plazmamc/plazma/Options.java
|
--- a/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/Options.java
|
+++ b/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
@@ -6,5 +6,7 @@ public interface Options {
|
@@ -8,5 +8,7 @@ public interface Options {
|
||||||
|
|
||||||
boolean NO_OPTIMIZE = getBoolean("Plazma.disableConfigOptimization");
|
boolean NO_OPTIMIZE = getBoolean("Plazma.disableConfigOptimization");
|
||||||
boolean AGGRESSIVE = Boolean.getBoolean("Plazma.aggressiveOptimize") && !NO_OPTIMIZE;
|
boolean NO_WARN = getBoolean("Plazma.iKnowWhatIAmDoing");
|
||||||
+ boolean VANILLAIZE = Boolean.getBoolean("Plazma.vanillaize") && !AGGRESSIVE;
|
boolean AGGRESSIVE = getBoolean("Plazma.aggressiveOptimize") && !NO_OPTIMIZE;
|
||||||
+ boolean USE_VANILLA = Boolean.getBoolean("Plazma.useVanillaConfiguration") && !AGGRESSIVE && NO_OPTIMIZE;
|
+ boolean VANILLAIZE = getBoolean("Plazma.vanillaize") && !AGGRESSIVE;
|
||||||
|
+ boolean USE_VANILLA = getBoolean("Plazma.useVanillaConfiguration") && !AGGRESSIVE && NO_OPTIMIZE;
|
||||||
|
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||||
@@ -7,7 +7,7 @@ Subject: [PATCH] Add entity spawn deadlock timer
|
|||||||
- AbsolemJackdaw/FixMySpawnR
|
- AbsolemJackdaw/FixMySpawnR
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||||
index 967af8771ff8564c715d89f4b4b69b16c25add59..2ac5fb585636523787e05edaa58a4fa34a39ef28 100644
|
index 79a8e5dd1d189c4eaf93999925ea0790eb6ce368..ac3b0f95926aba8e99375f74dfca9d83ca1fbd57 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||||
@@ -50,6 +50,8 @@ public abstract class BaseSpawner {
|
@@ -50,6 +50,8 @@ public abstract class BaseSpawner {
|
||||||
@@ -61,10 +61,10 @@ index 967af8771ff8564c715d89f4b4b69b16c25add59..2ac5fb585636523787e05edaa58a4fa3
|
|||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
index f5249795503b97b66644f59ff4a1afa66b6b6759..5978970f80b1b4672298426dcd8026e453025a52 100644
|
index a371893777a2c2d1de22e7d52f2fd3f55b82d74d..d366e8755ba91c329164c16659f6b07245577fba 100644
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
@@ -52,6 +52,14 @@ public class WorldConfigurations extends ConfigurationPart {
|
@@ -51,6 +51,14 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,4 +78,4 @@ index f5249795503b97b66644f59ff4a1afa66b6b6759..5978970f80b1b4672298426dcd8026e4
|
|||||||
+
|
+
|
||||||
}
|
}
|
||||||
|
|
||||||
public Structure structure;
|
public Block block;
|
||||||
@@ -20,10 +20,10 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
index dea61aeaf8b444c71fb54459b09486a9853772d1..6c43b022946e5c7260012802200cd64da4992b86 100644
|
index 32ebee3620b5ec1ff57b92a581fb2d7f5dfe17cf..214bd8084182ebd0d36cf9ddfac4411a5dce78be 100644
|
||||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
@@ -711,6 +711,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
@@ -697,6 +697,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||||
// Paper start - Add setting for proxy online mode status
|
// Paper start - Add setting for proxy online mode status
|
||||||
return dedicatedserverproperties.enforceSecureProfile
|
return dedicatedserverproperties.enforceSecureProfile
|
||||||
&& io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
|
&& io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
|
||||||
@@ -32,7 +32,7 @@ index dea61aeaf8b444c71fb54459b09486a9853772d1..6c43b022946e5c7260012802200cd64d
|
|||||||
// Paper end - Add setting for proxy online mode status
|
// Paper end - Add setting for proxy online mode status
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||||
index f78a0a224c86c0e3e5a44ce4f589cd8a61c546f9..69ff5380eedb3e0b214324dec50bb5c0eb65001b 100644
|
index 459eea7dae68afdf7e1443f29f6f8d0c68668b74..aead28160c7a5067340ec80a833eafcab1817d67 100644
|
||||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||||
@@ -135,6 +135,7 @@ public abstract class PlayerList {
|
@@ -135,6 +135,7 @@ public abstract class PlayerList {
|
||||||
@@ -52,10 +52,10 @@ index f78a0a224c86c0e3e5a44ce4f589cd8a61c546f9..69ff5380eedb3e0b214324dec50bb5c0
|
|||||||
player.loadGameTypes((CompoundTag) optional.orElse(null)); // CraftBukkit - decompile error
|
player.loadGameTypes((CompoundTag) optional.orElse(null)); // CraftBukkit - decompile error
|
||||||
ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData);
|
ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData);
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
index d0a1b97bacf9978b4955b1c2c4502c2c1312f1d4..c2caf205fa65382016b8340ff536c583b8234621 100644
|
index 5450d2a784511122a8236d30485f6b1f798822f3..a0b1239e302f0366743949a895a0539348817077 100644
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
@@ -29,6 +29,15 @@ public class GlobalConfiguration extends ConfigurationPart {
|
@@ -45,6 +45,15 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
public boolean checkSpectatorMovedToQuickly = !OPTIMIZE;
|
public boolean checkSpectatorMovedToQuickly = !OPTIMIZE;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ index d0a1b97bacf9978b4955b1c2c4502c2c1312f1d4..c2caf205fa65382016b8340ff536c583
|
|||||||
@Setting("world-generation")
|
@Setting("world-generation")
|
||||||
diff --git a/src/main/java/ru/bk/oharass/freedomchat/FreedomChat.java b/src/main/java/ru/bk/oharass/freedomchat/FreedomChat.java
|
diff --git a/src/main/java/ru/bk/oharass/freedomchat/FreedomChat.java b/src/main/java/ru/bk/oharass/freedomchat/FreedomChat.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..24ba82e13f6eeedd3a3658ebc29c9c4744f5f1b0
|
index 0000000000000000000000000000000000000000..49290983ef6b63bbacdef30f774ce683228e5755
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/ru/bk/oharass/freedomchat/FreedomChat.java
|
+++ b/src/main/java/ru/bk/oharass/freedomchat/FreedomChat.java
|
||||||
@@ -0,0 +1,103 @@
|
@@ -0,0 +1,103 @@
|
||||||
@@ -108,7 +108,7 @@ index 0000000000000000000000000000000000000000..24ba82e13f6eeedd3a3658ebc29c9c47
|
|||||||
+@ChannelHandler.Sharable
|
+@ChannelHandler.Sharable
|
||||||
+public class FreedomChat extends MessageToByteEncoder<Packet<?>> {
|
+public class FreedomChat extends MessageToByteEncoder<Packet<?>> {
|
||||||
+
|
+
|
||||||
+ private static final StreamCodec<ByteBuf, Packet<? super ClientGamePacketListener>> CODEC = GameProtocols.CLIENTBOUND
|
+ private static final StreamCodec<ByteBuf, Packet<? super ClientGamePacketListener>> CODEC = GameProtocols.CLIENTBOUND_TEMPLATE
|
||||||
+ .bind(RegistryFriendlyByteBuf.decorator(MinecraftServer.getServer().registryAccess())).codec();
|
+ .bind(RegistryFriendlyByteBuf.decorator(MinecraftServer.getServer().registryAccess())).codec();
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
373
patches/server/features/0035-Implement-Rail-Optimazition.patch
Normal file
373
patches/server/features/0035-Implement-Rail-Optimazition.patch
Normal file
@@ -0,0 +1,373 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Sat, 26 Oct 2024 12:33:57 +0900
|
||||||
|
Subject: [PATCH] Implement Rail Optimazition
|
||||||
|
|
||||||
|
Based on EasterGhost/RailOptimization, Original by FxMorin.
|
||||||
|
Copyright (C) 2024 EasterGhost, Licensed under GPL v3.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/ca/fxco/railoptimization/RailLogic.java b/src/main/java/ca/fxco/railoptimization/RailLogic.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..6c0a70c8902623991977c19a1c649488c9ad4afa
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/ca/fxco/railoptimization/RailLogic.java
|
||||||
|
@@ -0,0 +1,302 @@
|
||||||
|
+package ca.fxco.railoptimization;
|
||||||
|
+
|
||||||
|
+import net.minecraft.core.BlockPos;
|
||||||
|
+import net.minecraft.core.Direction;
|
||||||
|
+import net.minecraft.world.level.Level;
|
||||||
|
+import net.minecraft.world.level.block.Block;
|
||||||
|
+import net.minecraft.world.level.block.PoweredRailBlock;
|
||||||
|
+import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
+import net.minecraft.world.level.block.state.properties.RailShape;
|
||||||
|
+
|
||||||
|
+import java.util.HashMap;
|
||||||
|
+
|
||||||
|
+import static net.minecraft.world.level.block.PoweredRailBlock.POWERED;
|
||||||
|
+import static net.minecraft.world.level.block.PoweredRailBlock.SHAPE;
|
||||||
|
+import static net.minecraft.world.level.redstone.ExperimentalRedstoneUtils.initialOrientation;
|
||||||
|
+
|
||||||
|
+public class RailLogic {
|
||||||
|
+
|
||||||
|
+ private static final Direction[] EAST_WEST_DIR = new Direction[]{Direction.WEST, Direction.EAST};
|
||||||
|
+ private static final Direction[] NORTH_SOUTH_DIR = new Direction[]{Direction.SOUTH, Direction.NORTH};
|
||||||
|
+
|
||||||
|
+ private static final int UPDATE_FORCE_PLACE = Block.UPDATE_MOVE_BY_PISTON | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS;
|
||||||
|
+
|
||||||
|
+ public static void customUpdateState(PoweredRailBlock self, BlockState state, Level level, BlockPos pos) {
|
||||||
|
+ boolean shouldBePowered = level.hasNeighborSignal(pos) ||
|
||||||
|
+ self.findPoweredRailSignal(level, pos, state, true, 0) ||
|
||||||
|
+ self.findPoweredRailSignal(level, pos, state, false, 0);
|
||||||
|
+ if (shouldBePowered == state.getValue(POWERED)) return;
|
||||||
|
+
|
||||||
|
+ RailShape railShape = state.getValue(SHAPE);
|
||||||
|
+ if (railShape.isSlope()) {
|
||||||
|
+ level.setBlock(pos, state.setValue(POWERED, shouldBePowered), 3);
|
||||||
|
+ level.updateNeighborsAtExceptFromFacing(pos.below(), self, Direction.UP, initialOrientation(level, Direction.DOWN, Direction.UP));
|
||||||
|
+ level.updateNeighborsAtExceptFromFacing(pos.above(), self, Direction.DOWN, initialOrientation(level, Direction.UP, Direction.DOWN)); //isAscending
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (shouldBePowered) powerLane(self, level, pos, state, railShape);
|
||||||
|
+ else dePowerLane(self, level, pos, state, railShape);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void giveShapeUpdate(Level level, BlockState state, BlockPos pos, BlockPos fromPos, Direction direction) {
|
||||||
|
+ BlockState oldState = level.getBlockState(pos);
|
||||||
|
+ Block.updateOrDestroy(
|
||||||
|
+ oldState,
|
||||||
|
+ oldState.updateShape(level, level, pos, direction.getOpposite(), fromPos, state, level.getRandom()),
|
||||||
|
+ level,
|
||||||
|
+ pos,
|
||||||
|
+ Block.UPDATE_CLIENTS & -34,
|
||||||
|
+ 0
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean findPoweredRailSignalFaster(PoweredRailBlock self, Level level, BlockPos pos, boolean bl, int distance, RailShape shape, HashMap<BlockPos,Boolean> checkedPos) {
|
||||||
|
+ BlockState blockState = level.getBlockState(pos);
|
||||||
|
+ if (checkedPos.containsKey(pos) && checkedPos.get(pos))
|
||||||
|
+ return level.hasNeighborSignal(pos) || findPoweredRailSignalFaster(self, level, pos, blockState, bl, distance + 1, checkedPos);
|
||||||
|
+
|
||||||
|
+ if (!blockState.is(self)) return false;
|
||||||
|
+
|
||||||
|
+ RailShape railShape = blockState.getValue(SHAPE);
|
||||||
|
+ if (shape == RailShape.EAST_WEST && (railShape == RailShape.NORTH_SOUTH || railShape == RailShape.ASCENDING_NORTH || railShape == RailShape.ASCENDING_SOUTH) ||
|
||||||
|
+ shape == RailShape.NORTH_SOUTH && (railShape == RailShape.EAST_WEST || railShape == RailShape.ASCENDING_EAST || railShape == RailShape.ASCENDING_WEST)) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!blockState.getValue(POWERED)) return false;
|
||||||
|
+
|
||||||
|
+ return level.hasNeighborSignal(pos) ||
|
||||||
|
+ findPoweredRailSignalFaster(self, level, pos, blockState, bl, distance + 1, checkedPos);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean findPoweredRailSignalFaster(PoweredRailBlock self, Level level, BlockPos pos, BlockState state, boolean bl, int distance, HashMap<BlockPos, Boolean> checkedPos) {
|
||||||
|
+ if (distance >= level.purpurConfig.railActivationRange) return false;
|
||||||
|
+
|
||||||
|
+ int x = pos.getX();
|
||||||
|
+ int y = pos.getY();
|
||||||
|
+ int z = pos.getZ();
|
||||||
|
+ boolean bl2 = true;
|
||||||
|
+ RailShape railShape = state.getValue(SHAPE);
|
||||||
|
+
|
||||||
|
+ switch (railShape.ordinal()) {
|
||||||
|
+ case 0 -> {
|
||||||
|
+ if (bl) ++z;
|
||||||
|
+ else --z;
|
||||||
|
+ }
|
||||||
|
+ case 1 -> {
|
||||||
|
+ if (bl) --x;
|
||||||
|
+ else ++x;
|
||||||
|
+ }
|
||||||
|
+ case 2 -> {
|
||||||
|
+ if (bl) {
|
||||||
|
+ --x;
|
||||||
|
+ } else {
|
||||||
|
+ ++x;
|
||||||
|
+ ++y;
|
||||||
|
+ bl2 = false;
|
||||||
|
+ }
|
||||||
|
+ railShape = RailShape.EAST_WEST;
|
||||||
|
+ }
|
||||||
|
+ case 3 -> {
|
||||||
|
+ if (bl) {
|
||||||
|
+ --x;
|
||||||
|
+ ++y;
|
||||||
|
+ bl2 = false;
|
||||||
|
+ } else {
|
||||||
|
+ ++x;
|
||||||
|
+ }
|
||||||
|
+ railShape = RailShape.EAST_WEST;
|
||||||
|
+ }
|
||||||
|
+ case 4 -> {
|
||||||
|
+ if (bl) {
|
||||||
|
+ ++z;
|
||||||
|
+ } else {
|
||||||
|
+ --z;
|
||||||
|
+ ++y;
|
||||||
|
+ bl2 = false;
|
||||||
|
+ }
|
||||||
|
+ railShape = RailShape.NORTH_SOUTH;
|
||||||
|
+ }
|
||||||
|
+ case 5 -> {
|
||||||
|
+ if (bl) {
|
||||||
|
+ ++z;
|
||||||
|
+ ++y;
|
||||||
|
+ bl2 = false;
|
||||||
|
+ } else {
|
||||||
|
+ --z;
|
||||||
|
+ }
|
||||||
|
+ railShape = RailShape.NORTH_SOUTH;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return findPoweredRailSignalFaster(self, level, new BlockPos(x, y, z), bl, distance, railShape, checkedPos) ||
|
||||||
|
+ (bl2 && findPoweredRailSignalFaster(self, level, new BlockPos(x, y - 1, z), bl, distance, railShape, checkedPos));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void powerLane(PoweredRailBlock self, Level level, BlockPos pos, BlockState state, RailShape shape) {
|
||||||
|
+ level.setBlock(pos, state.setValue(POWERED, true), UPDATE_FORCE_PLACE);
|
||||||
|
+ HashMap<BlockPos,Boolean> checkedPos = new HashMap<>();
|
||||||
|
+ checkedPos.put(pos, true);
|
||||||
|
+ int[] count = new int[2];
|
||||||
|
+ if (shape == RailShape.NORTH_SOUTH) { //Order: +z, -z
|
||||||
|
+ for (int i = 0; i < NORTH_SOUTH_DIR.length; ++i) {
|
||||||
|
+ setRailPositionsPower(self, level, pos, checkedPos, count, i, NORTH_SOUTH_DIR[i]);
|
||||||
|
+ }
|
||||||
|
+ updateRailsNS(self, level, pos, state, count);
|
||||||
|
+ } else if (shape == RailShape.EAST_WEST) { //Order: -x, +x
|
||||||
|
+ for (int i = 0; i < EAST_WEST_DIR.length; ++i) {
|
||||||
|
+ setRailPositionsPower(self, level, pos, checkedPos, count, i, EAST_WEST_DIR[i]);
|
||||||
|
+ }
|
||||||
|
+ updateRailsEW(self, level, pos, state, count);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void dePowerLane(PoweredRailBlock self, Level level, BlockPos pos, BlockState state, RailShape shape) {
|
||||||
|
+ level.setBlock(pos, state.setValue(POWERED, false), UPDATE_FORCE_PLACE);
|
||||||
|
+ int[] count = new int[2];
|
||||||
|
+ if (shape == RailShape.NORTH_SOUTH) { //Order: +z, -z
|
||||||
|
+ for (int i = 0; i < NORTH_SOUTH_DIR.length; ++i) {
|
||||||
|
+ setRailPositionsDePower(self, level, pos, count, i, NORTH_SOUTH_DIR[i]);
|
||||||
|
+ }
|
||||||
|
+ updateRailsNS(self, level, pos, state, count);
|
||||||
|
+ } else if (shape == RailShape.EAST_WEST) { //Order: -x, +x
|
||||||
|
+ for (int i = 0; i < EAST_WEST_DIR.length; ++i) {
|
||||||
|
+ setRailPositionsDePower(self, level, pos, count, i, EAST_WEST_DIR[i]);
|
||||||
|
+ }
|
||||||
|
+ updateRailsEW(self, level, pos, state, count);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void setRailPositionsPower(PoweredRailBlock self, Level level, BlockPos pos, HashMap<BlockPos, Boolean> checkedPos, int[] count, int i, Direction dir) {
|
||||||
|
+ for (int z = 1; z < level.purpurConfig.railActivationRange; z++) {
|
||||||
|
+ BlockPos newPos = pos.relative(dir, z);
|
||||||
|
+ BlockState state = level.getBlockState(newPos);
|
||||||
|
+
|
||||||
|
+ if (checkedPos.containsKey(newPos)) {
|
||||||
|
+ if (!checkedPos.get(newPos)) break;
|
||||||
|
+ count[i]++;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!state.is(self) || state.getValue(POWERED) || !(
|
||||||
|
+ level.hasNeighborSignal(newPos) ||
|
||||||
|
+ findPoweredRailSignalFaster(self, level, newPos, state, true, 0, checkedPos) ||
|
||||||
|
+ findPoweredRailSignalFaster(self, level, newPos, state, false, 0, checkedPos)
|
||||||
|
+ )) {
|
||||||
|
+ checkedPos.put(newPos,false);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ checkedPos.put(newPos,true);
|
||||||
|
+ level.setBlock(newPos, state.setValue(POWERED, true), UPDATE_FORCE_PLACE);
|
||||||
|
+ count[i]++;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void setRailPositionsDePower(PoweredRailBlock self, Level level, BlockPos pos, int[] count, int i, Direction dir) {
|
||||||
|
+ for (int z = 1; z < level.purpurConfig.railActivationRange; z++) {
|
||||||
|
+ BlockPos newPos = pos.relative(dir, z);
|
||||||
|
+ BlockState state = level.getBlockState(newPos);
|
||||||
|
+ if (!state.is(self) || !state.getValue(POWERED) || level.hasNeighborSignal(newPos) ||
|
||||||
|
+ self.findPoweredRailSignal(level, newPos, state, true, 0) ||
|
||||||
|
+ self.findPoweredRailSignal(level, newPos, state, false, 0)) break;
|
||||||
|
+ level.setBlock(newPos, state.setValue(POWERED, false), UPDATE_FORCE_PLACE);
|
||||||
|
+ count[i]++;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void shapeUpdateEnd(PoweredRailBlock self, Level level, BlockPos pos, BlockState state, int endPos, Direction direction, int currentPos, BlockPos blockPos) {
|
||||||
|
+ if (currentPos != endPos) return;
|
||||||
|
+
|
||||||
|
+ BlockPos newPos = pos.relative(direction, currentPos+1);
|
||||||
|
+ giveShapeUpdate(level, state, newPos, pos, direction);
|
||||||
|
+
|
||||||
|
+ BlockState blockState = level.getBlockState(blockPos);
|
||||||
|
+ if (blockState.is(self) && blockState.getValue(SHAPE).isSlope()) giveShapeUpdate(level, state, newPos.above(), pos, direction);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void neighborUpdateEnd(PoweredRailBlock self, Level level, BlockPos pos, int endPos, Direction dir, Block block, int currentPos, BlockPos blockPos) {
|
||||||
|
+ if (currentPos != endPos) return;
|
||||||
|
+
|
||||||
|
+ BlockPos newPos = pos.relative(dir, currentPos+1);
|
||||||
|
+ level.neighborChanged(newPos, block, null); // TODO: Orientation
|
||||||
|
+
|
||||||
|
+ BlockState blockState = level.getBlockState(blockPos);
|
||||||
|
+ if (blockState.is(self) && blockState.getValue(SHAPE).isSlope()) level.neighborChanged(newPos.above(), block, null); // TODO: Orientation
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void updateRailsNeighborEW(PoweredRailBlock self, Level level, BlockPos pos, int c, Block block, Direction dir, int[] count, int countAmt) {
|
||||||
|
+ BlockPos pos1 = pos.relative(dir, c);
|
||||||
|
+ if (c == 0 && count[1] == 0) level.neighborChanged(pos1.relative(dir.getOpposite()), block, null); // TODO: Orientation
|
||||||
|
+ neighborUpdateEnd(self, level, pos, countAmt, dir, block, c, pos1);
|
||||||
|
+ level.neighborChanged(pos1.below(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos1.above(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos1.north(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos1.south(), block, null); // TODO: Orientation
|
||||||
|
+ BlockPos pos2 = pos.relative(dir, c).below();
|
||||||
|
+ level.neighborChanged(pos2.below(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos2.north(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos2.south(), block, null); // TODO: Orientation
|
||||||
|
+ if (c == countAmt) level.neighborChanged(pos.relative(dir, c + 1).below(), block, null); // TODO: Orientation
|
||||||
|
+ if (c == 0 && count[1] == 0) level.neighborChanged(pos1.relative(dir.getOpposite()).below(), block, null); // TODO: Orientation
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void updateRailsSectionEW(PoweredRailBlock self, Level level, BlockPos pos, int c, BlockState mainState, Direction dir, int[] count, int countAmt) {
|
||||||
|
+ BlockPos blockPos = pos.relative(dir, c);
|
||||||
|
+ if (c == 0 && count[1] == 0) giveShapeUpdate(level, mainState, blockPos.relative(dir.getOpposite()), pos, dir.getOpposite());
|
||||||
|
+ shapeUpdateEnd(self, level, pos, mainState, countAmt, dir, c, blockPos);
|
||||||
|
+ giveShapeUpdate(level, mainState, blockPos.below(), pos, Direction.DOWN);
|
||||||
|
+ giveShapeUpdate(level, mainState, blockPos.above(), pos, Direction.UP);
|
||||||
|
+ giveShapeUpdate(level, mainState, blockPos.north(), pos, Direction.NORTH);
|
||||||
|
+ giveShapeUpdate(level, mainState, blockPos.south(), pos, Direction.SOUTH);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void updateRailsNeighborNS(PoweredRailBlock self, Level level, BlockPos pos, int c, Block block, Direction dir, int[] count, int countAmt) {
|
||||||
|
+ BlockPos pos1 = pos.relative(dir,c);
|
||||||
|
+ level.neighborChanged(pos1.west(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos1.east(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos1.below(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos1.above(), block, null); // TODO: Orientation
|
||||||
|
+ neighborUpdateEnd(self, level, pos, countAmt, dir, block, c, pos1);
|
||||||
|
+ if (c == 0 && count[1] == 0) level.neighborChanged(pos1.relative(dir.getOpposite()), block, null); // TODO: Orientation
|
||||||
|
+ BlockPos pos2 = pos.relative(dir,c).below();
|
||||||
|
+ level.neighborChanged(pos2.west(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos2.east(), block, null); // TODO: Orientation
|
||||||
|
+ level.neighborChanged(pos2.below(), block, null); // TODO: Orientation
|
||||||
|
+ if (c == countAmt) level.neighborChanged(pos.relative(dir,c + 1).below(), block, null); // TODO: Orientation
|
||||||
|
+ if (c == 0 && count[1] == 0) level.neighborChanged(pos1.relative(dir.getOpposite()).below(), block, null); // TODO: Orientation
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void updateRailsSectionNS(PoweredRailBlock self, Level level, BlockPos pos, int c, BlockState state, Direction dir, int[] count, int countAmt) {
|
||||||
|
+ BlockPos blockPos = pos.relative(dir, c);
|
||||||
|
+ giveShapeUpdate(level, state, blockPos.west(), pos, Direction.WEST);
|
||||||
|
+ giveShapeUpdate(level, state, blockPos.east(), pos, Direction.EAST);
|
||||||
|
+ giveShapeUpdate(level, state, blockPos.below(), pos, Direction.DOWN);
|
||||||
|
+ giveShapeUpdate(level, state, blockPos.above(), pos, Direction.UP);
|
||||||
|
+ shapeUpdateEnd(self, level, pos, state, countAmt, dir, c, blockPos);
|
||||||
|
+ if (c == 0 && count[1] == 0) giveShapeUpdate(level, state, blockPos.relative(dir.getOpposite()), pos, dir.getOpposite());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void updateRailsEW(PoweredRailBlock self, Level level, BlockPos pos, BlockState state, int[] count) {
|
||||||
|
+ for (int i = 0; i < EAST_WEST_DIR.length; ++i) {
|
||||||
|
+ int countAmt = count[i];
|
||||||
|
+ if (i == 1 && countAmt == 0) continue;
|
||||||
|
+ Direction dir = EAST_WEST_DIR[i];
|
||||||
|
+ Block block = state.getBlock();
|
||||||
|
+ for (int c = countAmt; c >= i; c--) updateRailsNeighborEW(self, level, pos, c, block, dir, count, countAmt);
|
||||||
|
+ for (int c = countAmt; c >= i; c--) updateRailsSectionEW(self, level, pos, c, state, dir, count, countAmt);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void updateRailsNS(PoweredRailBlock self, Level level, BlockPos pos, BlockState state, int[] count) {
|
||||||
|
+ for (int i = 0; i < NORTH_SOUTH_DIR.length; ++i) {
|
||||||
|
+ int countAmt = count[i];
|
||||||
|
+ if (i == 1 && countAmt == 0) continue;
|
||||||
|
+ Direction dir = NORTH_SOUTH_DIR[i];
|
||||||
|
+ Block block = state.getBlock();
|
||||||
|
+ for (int c = countAmt; c >= i; c--) updateRailsNeighborNS(self, level, pos, c, block, dir, count, countAmt);
|
||||||
|
+ for (int c = countAmt; c >= i; c--) updateRailsSectionNS(self, level, pos, c, state, dir, count, countAmt);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java b/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java
|
||||||
|
index bd14c08defe8afc5ceca59d16a5b1dbad178f594..99dc44c569b6003b271ce2ea3f80cb194173ff95 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java
|
||||||
|
@@ -29,7 +29,7 @@ public class PoweredRailBlock extends BaseRailBlock {
|
||||||
|
this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_SOUTH)).setValue(PoweredRailBlock.POWERED, false)).setValue(PoweredRailBlock.WATERLOGGED, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
- protected boolean findPoweredRailSignal(Level world, BlockPos pos, BlockState state, boolean flag, int distance) {
|
||||||
|
+ public boolean findPoweredRailSignal(Level world, BlockPos pos, BlockState state, boolean flag, int distance) { // Plazma - protected -> public
|
||||||
|
if (distance >= world.purpurConfig.railActivationRange) { // Purpur
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
@@ -117,6 +117,12 @@ public class PoweredRailBlock extends BaseRailBlock {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateState(BlockState state, Level world, BlockPos pos, Block neighbor) {
|
||||||
|
+ // Plazma start - Optimize powered rail processing
|
||||||
|
+ if (world.plazmaConfig().block.rail.useFasterSignalSearch) {
|
||||||
|
+ ca.fxco.railoptimization.RailLogic.customUpdateState(this, state, world, pos);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - Optimize powered rail processing
|
||||||
|
boolean flag = (Boolean) state.getValue(PoweredRailBlock.POWERED);
|
||||||
|
boolean flag1 = world.hasNeighborSignal(pos) || this.findPoweredRailSignal(world, pos, state, true, 0) || this.findPoweredRailSignal(world, pos, state, false, 0);
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
index 9cfab16b9cdf40ccb709c0af66c406954560c0ef..0e27e4a1f767842d1dcd2ed235a6a45f120bf32e 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
@@ -72,6 +72,13 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public Rail rail;
|
||||||
|
+ public class Rail extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public boolean useFasterSignalSearch = OPTIMIZE;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item item;
|
||||||
@@ -0,0 +1,847 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Sat, 26 Oct 2024 18:30:26 +0900
|
||||||
|
Subject: [PATCH] Configurable RandomSource factory/provider
|
||||||
|
|
||||||
|
Xorshift Random: https://gist.github.com/Xyene/4637619
|
||||||
|
|
||||||
|
Based on AnOpenSauceDev/FastRandom
|
||||||
|
|
||||||
|
Copyright (C) 2024 AnOpenSauceDev
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
|
||||||
|
index 861bff267cb397e13e8e1c79bd0776b130c6e5da..266e56f2c2e6d8b760209b5d58c58333af5bd0c1 100644
|
||||||
|
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
|
||||||
|
@@ -21,7 +21,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
@DefaultQualifier(NonNull.class)
|
||||||
|
public class PaperLootableInventoryData {
|
||||||
|
|
||||||
|
- private static final Random RANDOM = new Random();
|
||||||
|
+ private static final Random RANDOM = java.util.concurrent.ThreadLocalRandom.current(); // Plazma - reduce creating random instance
|
||||||
|
|
||||||
|
private long lastFill = -1;
|
||||||
|
private long nextRefill = -1;
|
||||||
|
diff --git a/src/main/java/com/github/anopensaucedev/fasterrandom/util/math/random/RandomGeneratorRandom.java b/src/main/java/com/github/anopensaucedev/fasterrandom/util/math/random/RandomGeneratorRandom.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..a060fdbdc4daaffd9aafc707dc567cb56067d1e2
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/github/anopensaucedev/fasterrandom/util/math/random/RandomGeneratorRandom.java
|
||||||
|
@@ -0,0 +1,115 @@
|
||||||
|
+package com.github.anopensaucedev.fasterrandom.util.math.random;
|
||||||
|
+
|
||||||
|
+import com.google.common.annotations.VisibleForTesting;
|
||||||
|
+import net.minecraft.core.BlockPos;
|
||||||
|
+import net.minecraft.util.Mth;
|
||||||
|
+import net.minecraft.world.level.levelgen.BitRandomSource;
|
||||||
|
+import net.minecraft.world.level.levelgen.PositionalRandomFactory;
|
||||||
|
+import net.minecraft.util.RandomSource;
|
||||||
|
+import org.jspecify.annotations.NonNull;
|
||||||
|
+
|
||||||
|
+import java.util.random.RandomGenerator;
|
||||||
|
+import java.util.random.RandomGeneratorFactory;
|
||||||
|
+
|
||||||
|
+public class RandomGeneratorRandom implements BitRandomSource {
|
||||||
|
+ private static final @NonNull RandomGeneratorFactory<RandomGenerator.SplittableGenerator> FACTORY = RandomGeneratorFactory.of(org.plazmamc.plazma.Options.RANDOM_ALGOL);
|
||||||
|
+ private static final int INT_BITS = 48;
|
||||||
|
+ private static final long SEED_MASK = 0xFFFFFFFFFFFFL;
|
||||||
|
+ private static final long MULTIPLIER = 25214903917L;
|
||||||
|
+ private static final long INCREMENT = 11L;
|
||||||
|
+
|
||||||
|
+ private long seed;
|
||||||
|
+ private RandomGenerator.SplittableGenerator randomGenerator;
|
||||||
|
+
|
||||||
|
+ public RandomGeneratorRandom(long seed) {
|
||||||
|
+ this.seed = seed;
|
||||||
|
+ this.randomGenerator = FACTORY.create(seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource fork() {
|
||||||
|
+ return new RandomGeneratorRandom(this.nextLong());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull PositionalRandomFactory forkPositional() {
|
||||||
|
+ return new RandomGeneratorRandomFactory(this.nextLong());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setSeed(long seed) {
|
||||||
|
+ this.seed = seed;
|
||||||
|
+ this.randomGenerator = FACTORY.create(seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int next(int bits) {
|
||||||
|
+ // >>> instead of Mojang's >> fixes MC-239059
|
||||||
|
+ return (int) ((seed * MULTIPLIER + INCREMENT & SEED_MASK) >>> INT_BITS - bits);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int nextInt() {
|
||||||
|
+ return randomGenerator.nextInt();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int nextInt(int bound) {
|
||||||
|
+ return randomGenerator.nextInt(bound);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public long nextLong() {
|
||||||
|
+ return randomGenerator.nextLong();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean nextBoolean() {
|
||||||
|
+ return randomGenerator.nextBoolean();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public float nextFloat() {
|
||||||
|
+ return randomGenerator.nextFloat();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public double nextDouble() {
|
||||||
|
+ return randomGenerator.nextDouble();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public double nextGaussian() {
|
||||||
|
+ return randomGenerator.nextGaussian();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private record RandomGeneratorRandomFactory(long seed) implements PositionalRandomFactory {
|
||||||
|
+ @SuppressWarnings("deprecation")
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource at(int x, int y, int z) {
|
||||||
|
+ return new RandomGeneratorRandom(Mth.getSeed(x, y, z) ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @SuppressWarnings("deprecation")
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource at(final @NonNull BlockPos pos) {
|
||||||
|
+ return new RandomGeneratorRandom(Mth.getSeed(pos.getX(), pos.getY(), pos.getZ()) ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource fromHashOf(@NonNull String seed) {
|
||||||
|
+ return new RandomGeneratorRandom((long) seed.hashCode() ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource fromSeed(final long seed) {
|
||||||
|
+ return new RandomGeneratorRandom(seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ @VisibleForTesting
|
||||||
|
+ public void parityConfigString(@NonNull StringBuilder info) {
|
||||||
|
+ info.append("RandomGeneratorRandom$RandomGeneratorRandomFactory{").append(this.seed).append("}");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/util/RandomSource.java b/src/main/java/net/minecraft/util/RandomSource.java
|
||||||
|
index 252aef3ffe0fecd47ebea1ed7df48e14fa873eb9..f73f8faac05f90c646a23fadf3da565938a4f788 100644
|
||||||
|
--- a/src/main/java/net/minecraft/util/RandomSource.java
|
||||||
|
+++ b/src/main/java/net/minecraft/util/RandomSource.java
|
||||||
|
@@ -10,18 +10,39 @@ import net.minecraft.world.level.levelgen.ThreadSafeLegacyRandomSource;
|
||||||
|
public interface RandomSource {
|
||||||
|
@Deprecated
|
||||||
|
double GAUSSIAN_SPREAD_FACTOR = 2.297;
|
||||||
|
+ // Plazma start - Implement RandomGenerator support
|
||||||
|
+ java.util.function.LongFunction<RandomSource> FACTORY = switch (org.plazmamc.plazma.Options.RANDOM_FACTORY) {
|
||||||
|
+ case "legacy" -> LegacyRandomSource::new;
|
||||||
|
+ case "xoroshiro" -> net.minecraft.world.level.levelgen.XoroshiroRandomSource::new;
|
||||||
|
+ case "xorshift" -> org.plazmamc.plazma.util.random.XorshiftRandomSource::new;
|
||||||
|
+ case "secure" -> org.plazmamc.plazma.util.random.SecureRandomSource::new;
|
||||||
|
+ case "generator" -> {
|
||||||
|
+ try {
|
||||||
|
+ java.util.random.RandomGeneratorFactory.of(org.plazmamc.plazma.Options.RANDOM_ALGOL).create();
|
||||||
|
+ yield com.github.anopensaucedev.fasterrandom.util.math.random.RandomGeneratorRandom::new;
|
||||||
|
+ } catch (IllegalArgumentException ignored) {
|
||||||
|
+ net.minecraft.server.MinecraftServer.LOGGER.error("Your JDK does not support RandomGenerator! Update JDK or remove \"-DPlazma.randomSourceFactory\" from the startup flag");
|
||||||
|
+ net.minecraft.server.MinecraftServer.LOGGER.warn("Falling back to legacy random");
|
||||||
|
+ yield LegacyRandomSource::new;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ default -> throw new IllegalArgumentException("Invalid RandomSource: " + org.plazmamc.plazma.Options.RANDOM_FACTORY + ". Valid RandomSources are: legacy, xoroshiro, xorshift, generator");
|
||||||
|
+ };
|
||||||
|
+ @org.jspecify.annotations.Nullable RandomSource SHARED = org.plazmamc.plazma.Options.SHARED_RANDOM ? create() : null;
|
||||||
|
+ // Plazma end - Implement RandomGenerator support
|
||||||
|
|
||||||
|
static RandomSource create() {
|
||||||
|
- return create(RandomSupport.generateUniqueSeed());
|
||||||
|
+ return SHARED == null ? create(RandomSupport.generateUniqueSeed()) : SHARED; // Plazma - Configurable RandomSource
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
static RandomSource createThreadSafe() {
|
||||||
|
+ if (org.plazmamc.plazma.Options.NO_THREAD_SAFE) return create(); // Plazma - Configurable RandomSource
|
||||||
|
return new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
||||||
|
}
|
||||||
|
|
||||||
|
static RandomSource create(long seed) {
|
||||||
|
- return new LegacyRandomSource(seed);
|
||||||
|
+ return org.plazmamc.plazma.Options.IGNORE_SEED ? create() : FACTORY.apply(seed); // Plazma - Configurable RandomSource
|
||||||
|
}
|
||||||
|
|
||||||
|
static RandomSource createNewThreadLocalInstance() {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||||
|
index 27a6de70530c2a1cbe2f77a7fb493038121710ea..bbe093f7d5e0dc8e875f237058aa74c739967dd9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||||
|
@@ -395,7 +395,7 @@ public class PiglinAi {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean wantsToDance(LivingEntity piglin, LivingEntity target) {
|
||||||
|
- return target.getType() != EntityType.HOGLIN ? false : RandomSource.create(piglin.level().getGameTime()).nextFloat() < 0.1F;
|
||||||
|
+ return target.getType() != EntityType.HOGLIN ? false : (org.plazmamc.plazma.Options.SHARED_RANDOM ? piglin.random.nextFloat() : RandomSource.create(piglin.level().getGameTime()).nextFloat()) < 0.1F; // Plazma - reduce creating random instance
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean wantsToPickup(Piglin piglin, ItemStack stack) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||||
|
index 0e4c17c7246093d7fdb64a8f98536a84a8cfd978..0147a7be5fd147ffa9bd42a90e85a324bc317a81 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||||
|
@@ -343,7 +343,7 @@ public class StructureBlockEntity extends BlockEntity {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomSource createRandom(long seed) {
|
||||||
|
- return seed == 0L ? RandomSource.create(Util.getMillis()) : RandomSource.create(seed);
|
||||||
|
+ return seed == 0L ? RandomSource.create() : RandomSource.create(seed); // Plazma - reduce creating random instance
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean placeStructureIfSameSize(ServerLevel world) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java b/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java
|
||||||
|
index f1e0d3d7b1f458fcce83cf67762a16309123cdcb..6a8d5948f127ea87a0b4554ece4ad2c4c49a47c6 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java
|
||||||
|
@@ -120,7 +120,7 @@ public class StructurePlaceSettings {
|
||||||
|
}
|
||||||
|
|
||||||
|
public RandomSource getRandom(@Nullable BlockPos pos) {
|
||||||
|
- return this.random != null ? this.random : (pos == null ? RandomSource.create(Util.getMillis()) : RandomSource.create(Mth.getSeed(pos)));
|
||||||
|
+ return this.random != null ? this.random : (pos == null ? RandomSource.create() : RandomSource.create(Mth.getSeed(pos))); // Plazma - reduce creating random instance
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIgnoreEntities() {
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
index 5d7af6c1ec557d2a2813b87a64b8c8a99d2f87e0..deddf588826dda9b15beff3acf20be56837d240b 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
@@ -289,7 +289,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
- private static final Random rand = new Random();
|
||||||
|
+ private static final Random rand = java.util.concurrent.ThreadLocalRandom.current(); // Plazma - reduce creating random instance
|
||||||
|
|
||||||
|
public CraftWorld(ServerLevel world, ChunkGenerator gen, BiomeProvider biomeProvider, Environment env) {
|
||||||
|
this.world = world;
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||||||
|
index 759b6e54db93792c9862b1f1625118ac6fa49d7a..e81fa9aefc76af906ed1b6903f416f4d123689f5 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||||||
|
@@ -14,7 +14,7 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
|
public class CraftFirework extends CraftProjectile implements Firework {
|
||||||
|
|
||||||
|
- private final Random random = new Random();
|
||||||
|
+ private final net.minecraft.util.RandomSource random = net.minecraft.util.RandomSource.create(); // Plazma - Configurable RandomSource
|
||||||
|
//private CraftItemStack item; // Paper - Remove usage, not accurate representation of current item.
|
||||||
|
|
||||||
|
public CraftFirework(CraftServer server, FireworkRocketEntity entity) {
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/Options.java b/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
|
index e7092aeb5abce5aa5f9bd434adc6acd4e43dec13..5673e587247d0cd644e694ca68bdbb340676a73d 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/Options.java
|
||||||
|
@@ -11,5 +11,10 @@ public interface Options {
|
||||||
|
boolean VANILLAIZE = getBoolean("Plazma.vanillaize") && !AGGRESSIVE;
|
||||||
|
boolean USE_VANILLA = getBoolean("Plazma.useVanillaConfiguration") && !AGGRESSIVE && NO_OPTIMIZE;
|
||||||
|
boolean VANILLA_ICO = getBoolean("Plazma.useVanillaFavicon");
|
||||||
|
+ String RANDOM_FACTORY = getProperty("Plazma.randomSourceFactory", "legacy");
|
||||||
|
+ String RANDOM_ALGOL = getProperty("Plazma.randomSourceAlgorithm", "L64X128MixRandom");
|
||||||
|
+ boolean SHARED_RANDOM = getBoolean("Plazma.sharedRandomSource");
|
||||||
|
+ boolean IGNORE_SEED = getBoolean("Plazma.ignoreSeed") && SHARED_RANDOM;
|
||||||
|
+ boolean NO_THREAD_SAFE = getBoolean("Plazma.overrideThreadSafeRandom");
|
||||||
|
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/util/random/SecureRandomSource.java b/src/main/java/org/plazmamc/plazma/util/random/SecureRandomSource.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..5d08f040a05df5d24f4bf9747177c1720fe246fe
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/util/random/SecureRandomSource.java
|
||||||
|
@@ -0,0 +1,100 @@
|
||||||
|
+package org.plazmamc.plazma.util.random;
|
||||||
|
+
|
||||||
|
+import com.google.common.annotations.VisibleForTesting;
|
||||||
|
+import net.minecraft.core.BlockPos;
|
||||||
|
+import net.minecraft.util.Mth;
|
||||||
|
+import net.minecraft.util.RandomSource;
|
||||||
|
+import net.minecraft.world.level.levelgen.PositionalRandomFactory;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jspecify.annotations.NonNull;
|
||||||
|
+import java.security.SecureRandom;
|
||||||
|
+
|
||||||
|
+public class SecureRandomSource implements RandomSource {
|
||||||
|
+
|
||||||
|
+ private final SecureRandom random = new SecureRandom();
|
||||||
|
+
|
||||||
|
+ public SecureRandomSource(long seed) {
|
||||||
|
+ this.setSeed(seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull RandomSource fork() {
|
||||||
|
+ return new SecureRandomSource(this.nextLong());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull PositionalRandomFactory forkPositional() {
|
||||||
|
+ return new SecureRandomSourceFactory(this.nextLong());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setSeed(final long seed) {
|
||||||
|
+ this.random.setSeed(seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int nextInt() {
|
||||||
|
+ return this.random.nextInt();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int nextInt(final int bound) {
|
||||||
|
+ return this.random.nextInt(bound);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public long nextLong() {
|
||||||
|
+ return this.random.nextLong();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean nextBoolean() {
|
||||||
|
+ return this.random.nextBoolean();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public float nextFloat() {
|
||||||
|
+ return this.random.nextFloat();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public double nextDouble() {
|
||||||
|
+ return this.random.nextDouble();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public double nextGaussian() {
|
||||||
|
+ return this.random.nextGaussian();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private record SecureRandomSourceFactory(long seed) implements PositionalRandomFactory {
|
||||||
|
+ @SuppressWarnings("deprecation")
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource at(int x, int y, int z) {
|
||||||
|
+ return new SecureRandomSource(Mth.getSeed(x, y, z) ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @SuppressWarnings("deprecation")
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource at(final @NonNull BlockPos pos) {
|
||||||
|
+ return new SecureRandomSource(Mth.getSeed(pos.getX(), pos.getY(), pos.getZ()) ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource fromHashOf(@NonNull String seed) {
|
||||||
|
+ return new SecureRandomSource((long) seed.hashCode() ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource fromSeed(final long seed) {
|
||||||
|
+ return new SecureRandomSource(seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ @VisibleForTesting
|
||||||
|
+ public void parityConfigString(@NonNull StringBuilder info) {
|
||||||
|
+ info.append("SecureRandomSource$SecureRandomSourceFactory{").append(this.seed).append("}");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/util/random/XorshiftRandom.java b/src/main/java/org/plazmamc/plazma/util/random/XorshiftRandom.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..d9f08546997adb7e4f9b70ce913a4e92eced3a95
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/util/random/XorshiftRandom.java
|
||||||
|
@@ -0,0 +1,391 @@
|
||||||
|
+package org.plazmamc.plazma.util.random;
|
||||||
|
+
|
||||||
|
+import java.util.Random;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * A random number generator based on the simple and fast xor-shift pseudo
|
||||||
|
+ * random number generator (RNG) specified in:
|
||||||
|
+ * Marsaglia, George. (2003). <a href="https://web.archive.org/web/20070211044403/http://www.jstatsoft.org/v08/i14/xorshift.pdf">Xorshift RNGs.</a>
|
||||||
|
+ * Translated from: <a href="https://web.archive.org/web/20230919193645/https://www.codeproject.com/Articles/9187/A-fast-equivalent-for-System-Random">A fast equivalent for System.Random</a>.
|
||||||
|
+ * Original Code from: <a href="https://gist.github.com/Xyene/4637619">Xyene/Random.java</a>
|
||||||
|
+ */
|
||||||
|
+@SuppressWarnings("SuspiciousNameCombination")
|
||||||
|
+public class XorshiftRandom extends Random {
|
||||||
|
+ final double REAL_UNIT_INT = 1.0 / (0x7FFFFFFFL);
|
||||||
|
+ final double REAL_UNIT_UINT = 1.0 / (0xFFFFFFFFL);
|
||||||
|
+ final long Y = 842502087L, Z = 3579807591L, W = 273326509L;
|
||||||
|
+ long x, y, z, w;
|
||||||
|
+
|
||||||
|
+ public XorshiftRandom() {
|
||||||
|
+ seed((int) System.currentTimeMillis());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setSeed(long seed) {
|
||||||
|
+ seed((int) seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void seed(int seed) {
|
||||||
|
+ // The only stipulation stated for the xorshift RNG is that at least one of
|
||||||
|
+ // the seeds x,y,z,w is non-zero. We fulfill that requirement by only allowing
|
||||||
|
+ // resetting of the x seed
|
||||||
|
+ x = seed;
|
||||||
|
+ y = Y;
|
||||||
|
+ z = Z;
|
||||||
|
+ w = W;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ long boolBuffer;
|
||||||
|
+ int boolBufferBits = 0;
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean nextBoolean() {
|
||||||
|
+ if (boolBufferBits == 0) {
|
||||||
|
+ boolBuffer = nextUInt();
|
||||||
|
+ boolBufferBits = 32;
|
||||||
|
+ }
|
||||||
|
+ boolBuffer >>= 1;
|
||||||
|
+ boolean bit = (boolBuffer & 1) == 0;
|
||||||
|
+ --boolBufferBits;
|
||||||
|
+ return bit;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void nextBytes(byte[] buffer) {
|
||||||
|
+ // Fill up the bulk of the buffer in chunks of 4 bytes at a time.
|
||||||
|
+ long x = this.x, y = this.y, z = this.z, w = this.w;
|
||||||
|
+ int i = 0;
|
||||||
|
+ long t;
|
||||||
|
+ for (int bound = buffer.length - 3; i < bound; ) {
|
||||||
|
+ // Generate 4 bytes.
|
||||||
|
+ // Increased performance is achieved by generating 4 random bytes per loop.
|
||||||
|
+ // Also note that no mask needs to be applied to zero out the higher order bytes before
|
||||||
|
+ // casting because the cast ignores thos bytes. Thanks to Stefan Trosch黷z for pointing this out.
|
||||||
|
+ t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+ w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
|
||||||
|
+
|
||||||
|
+ buffer[i++] = (byte) w;
|
||||||
|
+ buffer[i++] = (byte) (w >> 8);
|
||||||
|
+ buffer[i++] = (byte) (w >> 16);
|
||||||
|
+ buffer[i++] = (byte) (w >> 24);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Fill up any remaining bytes in the buffer.
|
||||||
|
+ if (i < buffer.length) {
|
||||||
|
+ // Generate 4 bytes.
|
||||||
|
+ t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+ w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
|
||||||
|
+
|
||||||
|
+ buffer[i++] = (byte) w;
|
||||||
|
+ if (i < buffer.length) {
|
||||||
|
+ buffer[i++] = (byte) (w >> 8);
|
||||||
|
+ if (i < buffer.length) {
|
||||||
|
+ buffer[i++] = (byte) (w >> 16);
|
||||||
|
+ if (i < buffer.length) {
|
||||||
|
+ buffer[i] = (byte) (w >> 24);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ this.x = x;
|
||||||
|
+ this.y = y;
|
||||||
|
+ this.z = z;
|
||||||
|
+ this.w = w;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public double nextDouble() {
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+
|
||||||
|
+ // Here we can gain a 2x speed improvement by generating a value that can be cast to
|
||||||
|
+ // an int instead of the more easily available uint. If we then explicitly cast to an
|
||||||
|
+ // int the compiler will then cast the int to a double to perform the multiplication,
|
||||||
|
+ // this final cast is a lot faster than casting from a uint to a double. The extra cast
|
||||||
|
+ // to an int is very fast (the allocated bits remain the same) and so the overall effect
|
||||||
|
+ // of the extra cast is a significant performance improvement.
|
||||||
|
+ //
|
||||||
|
+ // Also note that the loss of one bit of precision is equivalent to what occurs within
|
||||||
|
+ // System.Random.
|
||||||
|
+ return (REAL_UNIT_INT * (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public double random() {
|
||||||
|
+ return nextDouble();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public float nextFloat() {
|
||||||
|
+ return (float) nextDouble();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int nextInt() {
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+ return (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int nextInt(int upperBound) {
|
||||||
|
+ if (upperBound < 0)
|
||||||
|
+ throw new IllegalArgumentException("upperBound must be >=0");
|
||||||
|
+
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+
|
||||||
|
+ return (int) ((REAL_UNIT_INT * (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * upperBound);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int nextInt(int lowerBound, int upperBound) {
|
||||||
|
+ if (lowerBound > upperBound)
|
||||||
|
+ throw new IllegalArgumentException("upperBound must be >=lowerBound");
|
||||||
|
+
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+
|
||||||
|
+ // The explicit int cast before the first multiplication gives better performance.
|
||||||
|
+ // See comments in NextDouble.
|
||||||
|
+ int range = upperBound - lowerBound;
|
||||||
|
+ if (range < 0) {
|
||||||
|
+ // If range is <0 then an overflow has occured and must resort to using long integer arithmetic instead (slower).
|
||||||
|
+ // We also must use all 32 bits of precision, instead of the normal 31, which again is slower.
|
||||||
|
+ return lowerBound + (int) ((REAL_UNIT_UINT * (double) (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))) * (double) ((long) upperBound - (long) lowerBound));
|
||||||
|
+ }
|
||||||
|
+ // 31 bits of precision will suffice if range<=int.MaxValue. This allows us to cast to an int and gain
|
||||||
|
+ // a little more performance.
|
||||||
|
+ return lowerBound + (int) ((REAL_UNIT_INT * (double) (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * (double) range);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public long nextUInt() {
|
||||||
|
+ long t = (x ^ (x << 11));
|
||||||
|
+ x = y;
|
||||||
|
+ y = z;
|
||||||
|
+ z = w;
|
||||||
|
+ return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))) & (0xFFFFFFFFL);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public long nextLong() {
|
||||||
|
+ return nextUInt() << 32 + nextUInt();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ double gaussNext;
|
||||||
|
+ boolean hasGaussNext;
|
||||||
|
+ final double TWOPI = Math.PI * 2;
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Get a random number in the range [min, max) or [min, max] depending on rounding.
|
||||||
|
+ *
|
||||||
|
+ * @param min Low bound
|
||||||
|
+ * @param max High bound
|
||||||
|
+ * @return A uniformly distributed double
|
||||||
|
+ */
|
||||||
|
+ public double uniform(double min, double max) {
|
||||||
|
+ return min + (max - min) * nextDouble();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Triangular distribution.
|
||||||
|
+ * <p/>
|
||||||
|
+ * Continuous distribution bounded by given lower and upper limits,
|
||||||
|
+ * and having a given mode value in-between.
|
||||||
|
+ * See: <a href="http://en.wikipedia.org/wiki/Triangular_distribution">Triangular distribution</a>
|
||||||
|
+ *
|
||||||
|
+ * @param low Low bound
|
||||||
|
+ * @param high High bound
|
||||||
|
+ * @param mode Mode
|
||||||
|
+ * @return A number from the triangular distribution specified
|
||||||
|
+ */
|
||||||
|
+ public double triangular(int low, int high, int mode) {
|
||||||
|
+ double u = nextDouble();
|
||||||
|
+ double c = (double) (mode - low) / (high - low);
|
||||||
|
+ if (u > c) {
|
||||||
|
+ u = 1.0 - u;
|
||||||
|
+ c = 1.0 - c;
|
||||||
|
+ int k = low;
|
||||||
|
+ low = high;
|
||||||
|
+ high = k;
|
||||||
|
+ }
|
||||||
|
+ return low + (high - low) * Math.sqrt(u * c);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gaussian distribution, mean is 0 and standard deviation is 1.
|
||||||
|
+ * <p/>
|
||||||
|
+ * mu is the mean, and sigma is the standard deviation.
|
||||||
|
+ *
|
||||||
|
+ * @return A double in Gaussian distribution
|
||||||
|
+ */
|
||||||
|
+ public double gauss() {
|
||||||
|
+ return nextGaussian();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gaussian distribution, with user-specified mean and standard deviation.
|
||||||
|
+ * <p/>
|
||||||
|
+ * mu is the mean, and sigma is the standard deviation.
|
||||||
|
+ *
|
||||||
|
+ * @return A double in Gaussian distribution
|
||||||
|
+ */
|
||||||
|
+ public double gauss(double mu, double sigma) {
|
||||||
|
+ return mu + sigma * nextGaussian();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public double gaussUnsigned(double mu, double sigma) {
|
||||||
|
+ double out = gauss(mu, sigma);
|
||||||
|
+ return out > 1 ? out : 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Log normal distribution.
|
||||||
|
+ * <p/>
|
||||||
|
+ * If you take the natural logarithm of this distribution, you'll get a
|
||||||
|
+ * normal distribution with mean mu and standard deviation sigma.
|
||||||
|
+ * mu can have any value, and sigma must be greater than zero.
|
||||||
|
+ *
|
||||||
|
+ * @param mu Mean
|
||||||
|
+ * @param sigma Standard deviation
|
||||||
|
+ * @return A number from the log normal distribution specified
|
||||||
|
+ */
|
||||||
|
+ public double logNormal(double mu, double sigma) {
|
||||||
|
+ return Math.exp(gauss(mu, sigma));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Exponential distribution.
|
||||||
|
+ * <p/>
|
||||||
|
+ * lambda is 1.0 divided by the desired mean. It should be
|
||||||
|
+ * nonzero. Returned values range from 0 to positive infinity
|
||||||
|
+ * if lambda is positive, and from negative infinity to 0
|
||||||
|
+ * if lambda is negative.
|
||||||
|
+ *
|
||||||
|
+ * @param lambda A non-zero value
|
||||||
|
+ */
|
||||||
|
+ public double exponential(double lambda) {
|
||||||
|
+ return -Math.log(1.0 - random()) / lambda;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Circular data distribution.
|
||||||
|
+ * <p/>
|
||||||
|
+ * If kappa is equal to zero, this distribution reduces
|
||||||
|
+ * to a uniform random angle over the range 0 to 2*pi.
|
||||||
|
+ *
|
||||||
|
+ * @param mu the mean angle, expressed in radians between 0 and 2*pi.
|
||||||
|
+ * @param kappa the concentration parameter, which must be greater than or
|
||||||
|
+ * equal to zero.
|
||||||
|
+ * @return A number from the circular data distribution specified
|
||||||
|
+ */
|
||||||
|
+ public double circularData(double mu, double kappa) {
|
||||||
|
+ if (kappa <= 1e-6)
|
||||||
|
+ return TWOPI * nextDouble();
|
||||||
|
+
|
||||||
|
+ double a = 1.0 + Math.sqrt(1.0 + 4.0 * kappa * kappa);
|
||||||
|
+ double b = (a - Math.sqrt(2.0 * a)) / (2.0 * kappa);
|
||||||
|
+ double r = (1.0 + b * b) / (2.0 * b);
|
||||||
|
+ double u1, u2, u3, f, c, z, theta = 0;
|
||||||
|
+
|
||||||
|
+ while (true) {
|
||||||
|
+ u1 = nextDouble();
|
||||||
|
+
|
||||||
|
+ z = Math.cos(Math.PI * u1);
|
||||||
|
+ f = (1.0 + r * z) / (r + z);
|
||||||
|
+ c = kappa * (r - f);
|
||||||
|
+
|
||||||
|
+ u2 = nextDouble();
|
||||||
|
+
|
||||||
|
+ if (u2 < c * (2.0 - c) || u2 <= c * Math.exp(1.0 - c))
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ u3 = nextDouble();
|
||||||
|
+ if (u3 > 0.5)
|
||||||
|
+ theta = (mu % TWOPI) + Math.acos(f);
|
||||||
|
+ else
|
||||||
|
+ theta = (mu % TWOPI) - Math.acos(f);
|
||||||
|
+ }
|
||||||
|
+ return theta;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ final double LOG4 = Math.log(4);
|
||||||
|
+ final double SG_MAGICCONST = 1.0 + Math.log(4.5);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gamma distribution. Not the gamma function!
|
||||||
|
+ * Conditions on the parameters are alpha > 0 and beta > 0.
|
||||||
|
+ * <p/>
|
||||||
|
+ * The probability distribution function is:
|
||||||
|
+ * pdf(x) = (x ** (alpha - 1) * math.exp(-x / beta)) / (math.gamma(alpha) * beta ** alpha)
|
||||||
|
+ *
|
||||||
|
+ * @param alpha Alpha
|
||||||
|
+ * @param beta Beta
|
||||||
|
+ * @return A number from the gamma distribution specified
|
||||||
|
+ */
|
||||||
|
+ public double gamma(double alpha, double beta) {
|
||||||
|
+ if (alpha <= 0.0 || beta <= 0.0)
|
||||||
|
+ throw new IllegalArgumentException("alpha and beta must be > 0.0");
|
||||||
|
+
|
||||||
|
+ if (alpha > 1.0) {
|
||||||
|
+ double ainv = Math.sqrt(2.0 * alpha - 1.0);
|
||||||
|
+ double bbb = alpha - LOG4;
|
||||||
|
+ double ccc = alpha + ainv;
|
||||||
|
+ double u1, u2, v, x, z, r;
|
||||||
|
+
|
||||||
|
+ while (true) {
|
||||||
|
+ u1 = random();
|
||||||
|
+ if (!(1e-7 < u1 && u1 < .9999999))
|
||||||
|
+ continue;
|
||||||
|
+ u2 = 1.0 - random();
|
||||||
|
+ v = Math.log(u1 / (1.0 - u1)) / ainv;
|
||||||
|
+ x = alpha * Math.exp(v);
|
||||||
|
+ z = u1 * u1 * u2;
|
||||||
|
+ r = bbb + ccc * v - x;
|
||||||
|
+ if (r + SG_MAGICCONST - 4.5 * z >= 0.0 || r >= Math.log(z))
|
||||||
|
+ return x * beta;
|
||||||
|
+ }
|
||||||
|
+ } else if (alpha == 1.0) {
|
||||||
|
+ // exponential(1)
|
||||||
|
+ double u;
|
||||||
|
+ u = random();
|
||||||
|
+ while (u <= 1e-7)
|
||||||
|
+ u = random();
|
||||||
|
+ return -Math.log(u) * beta;
|
||||||
|
+ } else {
|
||||||
|
+ // alpha is between 0 and 1 (exclusive)
|
||||||
|
+ // Uses ALGORITHM GS of Statistical Computing -Kennedy & Gentle
|
||||||
|
+
|
||||||
|
+ double u, b, p, x, u1;
|
||||||
|
+ while (true) {
|
||||||
|
+ u = random();
|
||||||
|
+ b = (Math.E + alpha) / Math.E;
|
||||||
|
+ p = b * u;
|
||||||
|
+ if (p <= 1.0)
|
||||||
|
+ x = Math.pow(p, (1.0 / alpha));
|
||||||
|
+ else
|
||||||
|
+ x = -Math.log((b - p) / alpha);
|
||||||
|
+ u1 = random();
|
||||||
|
+ if (p > 1.0) {
|
||||||
|
+ if (u1 <= Math.pow(x, (alpha - 1.0)))
|
||||||
|
+ break;
|
||||||
|
+ } else if (u1 <= Math.exp(-x))
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ return x * beta;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/util/random/XorshiftRandomSource.java b/src/main/java/org/plazmamc/plazma/util/random/XorshiftRandomSource.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..646e9689f17211112f8d253099fb075666d942e9
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/util/random/XorshiftRandomSource.java
|
||||||
|
@@ -0,0 +1,56 @@
|
||||||
|
+package org.plazmamc.plazma.util.random;
|
||||||
|
+
|
||||||
|
+import com.google.common.annotations.VisibleForTesting;
|
||||||
|
+import net.minecraft.core.BlockPos;
|
||||||
|
+import net.minecraft.util.Mth;
|
||||||
|
+import net.minecraft.util.RandomSource;
|
||||||
|
+import net.minecraft.world.level.levelgen.PositionalRandomFactory;
|
||||||
|
+import org.jspecify.annotations.NonNull;
|
||||||
|
+
|
||||||
|
+public class XorshiftRandomSource extends XorshiftRandom implements RandomSource {
|
||||||
|
+
|
||||||
|
+ public XorshiftRandomSource(long seed) {
|
||||||
|
+ this.setSeed(seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource fork() {
|
||||||
|
+ return new XorshiftRandomSource(this.nextLong());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull PositionalRandomFactory forkPositional() {
|
||||||
|
+ return new XorshiftRandomSourceFactory(this.nextLong());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private record XorshiftRandomSourceFactory(long seed) implements PositionalRandomFactory {
|
||||||
|
+ @SuppressWarnings("deprecation")
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource at(int x, int y, int z) {
|
||||||
|
+ return new XorshiftRandomSource(Mth.getSeed(x, y, z) ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @SuppressWarnings("deprecation")
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource at(final @NonNull BlockPos pos) {
|
||||||
|
+ return new XorshiftRandomSource(Mth.getSeed(pos.getX(), pos.getY(), pos.getZ()) ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource fromHashOf(@NonNull String seed) {
|
||||||
|
+ return new XorshiftRandomSource((long) seed.hashCode() ^ this.seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NonNull RandomSource fromSeed(final long seed) {
|
||||||
|
+ return new XorshiftRandomSource(seed);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ @VisibleForTesting
|
||||||
|
+ public void parityConfigString(@NonNull StringBuilder info) {
|
||||||
|
+ info.append("XorshiftRandomSource$XorshiftRandomSourceFactory{").append(this.seed).append("}");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
@@ -464,12 +464,12 @@ index 0000000000000000000000000000000000000000..3456f38d381643b0461669b0b5fec6bf
|
|||||||
+
|
+
|
||||||
+}
|
+}
|
||||||
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
|
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 ecd1bbd17cb0134cf1f4e99a3fea9e205d38f46b..a064bca7d59dc645b28d5c4d92611d7aff5d3c7d 100644
|
index 273ba657926ce72a7c82861e880a82bf7f322a0b..f90a14860e4c9a11a972edc3cea011e1cf67b4eb 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||||
@@ -76,6 +76,35 @@ public class AcquirePoi {
|
@@ -94,6 +94,35 @@ public class AcquirePoi {
|
||||||
io.papermc.paper.util.PoiAccess.findNearestPoiPositions(poiManager, poiPredicate, predicate2, entity.blockPosition(), world.purpurConfig.villagerAcquirePoiSearchRadius, world.purpurConfig.villagerAcquirePoiSearchRadius*world.purpurConfig.villagerAcquirePoiSearchRadius, PoiManager.Occupancy.HAS_SPACE, false, 5, poiposes); // Purpur
|
}
|
||||||
Set<Pair<Holder<PoiType>, BlockPos>> set = new java.util.HashSet<>(poiposes);
|
}
|
||||||
// Paper end - optimise POI access
|
// Paper end - optimise POI access
|
||||||
+ // Plazma start - Process Pathfinding Asynchronously
|
+ // Plazma start - Process Pathfinding Asynchronously
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) {
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) {
|
||||||
@@ -478,7 +478,7 @@ index ecd1bbd17cb0134cf1f4e99a3fea9e205d38f46b..a064bca7d59dc645b28d5c4d92611d7a
|
|||||||
+ if (path == null || !path.canReach()) {
|
+ if (path == null || !path.canReach()) {
|
||||||
+ for (Pair<Holder<PoiType>, BlockPos> pair : set) long2ObjectMap.computeIfAbsent(
|
+ for (Pair<Holder<PoiType>, BlockPos> pair : set) long2ObjectMap.computeIfAbsent(
|
||||||
+ pair.getSecond().asLong(),
|
+ pair.getSecond().asLong(),
|
||||||
+ ignored -> new JitteredLinearRetry(entity.level().random, time)
|
+ ignored -> new net.minecraft.world.entity.ai.behavior.AcquirePoi.JitteredLinearRetry(entity.level().random, time)
|
||||||
+ );
|
+ );
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
@@ -653,23 +653,23 @@ index 6802e0c4d331c7125114dd86409f6a110465ab82..0b8973765bcaa77e70ac7afe5b6a99ab
|
|||||||
if (path != null && path.canReach()) {
|
if (path != null && path.canReach()) {
|
||||||
BlockPos blockPos = path.getTarget();
|
BlockPos blockPos = path.getTarget();
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
||||||
index 74aca307b4ebffe4e33c4fca3e07c23ca87622ac..a1c99a611c9b0c99d851393c668fe02c5a31536f 100644
|
index 2846790fcd00788cf0284c348161ee1aee415f13..069e27041434c11ae5235ccb0e17544fe4a14e12 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
||||||
@@ -56,7 +56,7 @@ public abstract class DoorInteractGoal extends Goal {
|
@@ -56,7 +56,7 @@ public abstract class DoorInteractGoal extends Goal {
|
||||||
} else {
|
} else {
|
||||||
GroundPathNavigation groundPathNavigation = (GroundPathNavigation)this.mob.getNavigation();
|
GroundPathNavigation groundPathNavigation = (GroundPathNavigation)this.mob.getNavigation();
|
||||||
Path path = groundPathNavigation.getPath();
|
Path path = groundPathNavigation.getPath();
|
||||||
- if (path != null && !path.isDone() && groundPathNavigation.canOpenDoors()) {
|
- if (path != null && !path.isDone()) {
|
||||||
+ if (path != null && path.isProcessed() && !path.isDone() && groundPathNavigation.canOpenDoors()) { // Plazma - Process Pathfinding asynchronously
|
+ if (path != null && path.isProcessed() && !path.isDone()) { // Plazma - Process Pathfinding asynchronously
|
||||||
for (int i = 0; i < Math.min(path.getNextNodeIndex() + 2, path.getNodeCount()); i++) {
|
for (int i = 0; i < Math.min(path.getNextNodeIndex() + 2, path.getNodeCount()); i++) {
|
||||||
Node node = path.getNode(i);
|
Node node = path.getNode(i);
|
||||||
this.doorPos = new BlockPos(node.x, node.y + 1, node.z);
|
this.doorPos = new BlockPos(node.x, node.y + 1, node.z);
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||||
index ee38e447a810094d2253b85714b74282a4b4c2bc..8361b230963469d564d6280414ea083e975f9cf7 100644
|
index 29b852c3262c9cd0d2c77a93c01a386a2c184742..8361b230963469d564d6280414ea083e975f9cf7 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||||
@@ -12,12 +12,26 @@ public class AmphibiousPathNavigation extends PathNavigation {
|
@@ -12,11 +12,26 @@ public class AmphibiousPathNavigation extends PathNavigation {
|
||||||
super(mob, world);
|
super(mob, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -687,7 +687,7 @@ index ee38e447a810094d2253b85714b74282a4b4c2bc..8361b230963469d564d6280414ea083e
|
|||||||
@Override
|
@Override
|
||||||
protected PathFinder createPathFinder(int range) {
|
protected PathFinder createPathFinder(int range) {
|
||||||
this.nodeEvaluator = new AmphibiousNodeEvaluator(false);
|
this.nodeEvaluator = new AmphibiousNodeEvaluator(false);
|
||||||
this.nodeEvaluator.setCanPassDoors(true);
|
+ this.nodeEvaluator.setCanPassDoors(true);
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
||||||
+ return new PathFinder(this.nodeEvaluator, range, GENERATOR);
|
+ return new PathFinder(this.nodeEvaluator, range, GENERATOR);
|
||||||
return new PathFinder(this.nodeEvaluator, range);
|
return new PathFinder(this.nodeEvaluator, range);
|
||||||
@@ -697,10 +697,10 @@ index ee38e447a810094d2253b85714b74282a4b4c2bc..8361b230963469d564d6280414ea083e
|
|||||||
@Override
|
@Override
|
||||||
protected boolean canUpdatePath() {
|
protected boolean canUpdatePath() {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||||
index a3e0c5af4cc9323c02e88e768cbda9e46854aea1..d68e97084ba6bc97312fc5b62ffcb6e6b21b056e 100644
|
index 2bd66da93227d4e4fc2ec4df47ae94b17f4d39d3..ee395676b5eb14cd24b7251a83be7154d71b7b20 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||||
@@ -16,12 +16,26 @@ public class FlyingPathNavigation extends PathNavigation {
|
@@ -16,11 +16,26 @@ public class FlyingPathNavigation extends PathNavigation {
|
||||||
super(entity, world);
|
super(entity, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -713,12 +713,12 @@ index a3e0c5af4cc9323c02e88e768cbda9e46854aea1..d68e97084ba6bc97312fc5b62ffcb6e6
|
|||||||
+ evaluator.setCanFloat(features.canFloat());
|
+ evaluator.setCanFloat(features.canFloat());
|
||||||
+ evaluator.setCanWalkOverFences(features.canWalkOverFences());
|
+ evaluator.setCanWalkOverFences(features.canWalkOverFences());
|
||||||
+ return evaluator;
|
+ return evaluator;
|
||||||
+ };
|
+ };
|
||||||
+
|
+
|
||||||
@Override
|
@Override
|
||||||
protected PathFinder createPathFinder(int range) {
|
protected PathFinder createPathFinder(int range) {
|
||||||
this.nodeEvaluator = new FlyNodeEvaluator();
|
this.nodeEvaluator = new FlyNodeEvaluator();
|
||||||
this.nodeEvaluator.setCanPassDoors(true);
|
+ this.nodeEvaluator.setCanPassDoors(true);
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
||||||
+ return new PathFinder(this.nodeEvaluator, range, GENERATOR);
|
+ return new PathFinder(this.nodeEvaluator, range, GENERATOR);
|
||||||
return new PathFinder(this.nodeEvaluator, range);
|
return new PathFinder(this.nodeEvaluator, range);
|
||||||
@@ -727,7 +727,7 @@ index a3e0c5af4cc9323c02e88e768cbda9e46854aea1..d68e97084ba6bc97312fc5b62ffcb6e6
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canMoveDirectly(Vec3 origin, Vec3 target) {
|
protected boolean canMoveDirectly(Vec3 origin, Vec3 target) {
|
||||||
@@ -50,6 +64,7 @@ public class FlyingPathNavigation extends PathNavigation {
|
@@ -49,6 +64,7 @@ public class FlyingPathNavigation extends PathNavigation {
|
||||||
this.recomputePath();
|
this.recomputePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -736,10 +736,10 @@ index a3e0c5af4cc9323c02e88e768cbda9e46854aea1..d68e97084ba6bc97312fc5b62ffcb6e6
|
|||||||
if (this.canUpdatePath()) {
|
if (this.canUpdatePath()) {
|
||||||
this.followThePath();
|
this.followThePath();
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||||
index 62634bedd97c5be9ecce24ab0cff205715a68da8..d7bbb9ddb97b336a2198b07cb2395f1b8b8e9d30 100644
|
index 2796df7af365c452b28373adfd7daf1d6730bac5..921b0f792fbb3e7a0bb0275d8494a19830a08eae 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||||
@@ -23,12 +23,26 @@ public class GroundPathNavigation extends PathNavigation {
|
@@ -24,11 +24,25 @@ public class GroundPathNavigation extends PathNavigation {
|
||||||
super(entity, world);
|
super(entity, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,9 +757,8 @@ index 62634bedd97c5be9ecce24ab0cff205715a68da8..d7bbb9ddb97b336a2198b07cb2395f1b
|
|||||||
@Override
|
@Override
|
||||||
protected PathFinder createPathFinder(int range) {
|
protected PathFinder createPathFinder(int range) {
|
||||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||||
this.nodeEvaluator.setCanPassDoors(true);
|
+ this.nodeEvaluator.setCanPassDoors(true);
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) return new PathFinder(this.nodeEvaluator, range, GENERATOR);
|
||||||
+ return new PathFinder(this.nodeEvaluator, range, GENERATOR);
|
|
||||||
return new PathFinder(this.nodeEvaluator, range);
|
return new PathFinder(this.nodeEvaluator, range);
|
||||||
}
|
}
|
||||||
+ // Plazma end - Process pathfinding asynchronously
|
+ // Plazma end - Process pathfinding asynchronously
|
||||||
@@ -767,10 +766,10 @@ index 62634bedd97c5be9ecce24ab0cff205715a68da8..d7bbb9ddb97b336a2198b07cb2395f1b
|
|||||||
@Override
|
@Override
|
||||||
protected boolean canUpdatePath() {
|
protected boolean canUpdatePath() {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||||
index 544920a31b649985333f82beafa94a3392f5853e..05715fa17caf8d8eece85b7ad752f57890b04716 100644
|
index 48c0de870a5bbf647309e69361dfb10ab56c65ab..99e31c8e8488ce7138c5385575cbbabe0bd7394e 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||||
@@ -152,6 +152,7 @@ public abstract class PathNavigation {
|
@@ -168,6 +168,7 @@ public abstract class PathNavigation {
|
||||||
return null;
|
return null;
|
||||||
} else if (!this.canUpdatePath()) {
|
} else if (!this.canUpdatePath()) {
|
||||||
return null;
|
return null;
|
||||||
@@ -778,11 +777,10 @@ index 544920a31b649985333f82beafa94a3392f5853e..05715fa17caf8d8eece85b7ad752f578
|
|||||||
} else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) {
|
} else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) {
|
||||||
return this.path;
|
return this.path;
|
||||||
} else {
|
} else {
|
||||||
@@ -177,7 +178,23 @@ public abstract class PathNavigation {
|
@@ -195,6 +196,23 @@ public abstract class PathNavigation {
|
||||||
int i = (int)(followRange + (float)range);
|
|
||||||
PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i));
|
PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i));
|
||||||
Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, positions, followRange, distance, this.maxVisitedNodesMultiplier);
|
Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, positions, followRange, distance, this.maxVisitedNodesMultiplier);
|
||||||
- //this.level.getProfiler().pop(); // Purpur
|
profilerFiller.pop();
|
||||||
+ // Plazma start - Process pathfinding asynchronously
|
+ // Plazma start - Process pathfinding asynchronously
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) {
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) {
|
||||||
+ if (!positions.isEmpty()) this.targetPos = positions.iterator().next();
|
+ if (!positions.isEmpty()) this.targetPos = positions.iterator().next();
|
||||||
@@ -799,11 +797,11 @@ index 544920a31b649985333f82beafa94a3392f5853e..05715fa17caf8d8eece85b7ad752f578
|
|||||||
+
|
+
|
||||||
+ return path;
|
+ return path;
|
||||||
+ }
|
+ }
|
||||||
+ // Plazma end
|
+ // Plazma end - Process pathfinding asynchronously
|
||||||
if (path != null && path.getTarget() != null) {
|
if (path != null && path.getTarget() != null) {
|
||||||
this.targetPos = path.getTarget();
|
this.targetPos = path.getTarget();
|
||||||
this.reachRange = distance;
|
this.reachRange = distance;
|
||||||
@@ -233,8 +250,8 @@ public abstract class PathNavigation {
|
@@ -250,8 +268,8 @@ public abstract class PathNavigation {
|
||||||
if (this.isDone()) {
|
if (this.isDone()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -814,7 +812,7 @@ index 544920a31b649985333f82beafa94a3392f5853e..05715fa17caf8d8eece85b7ad752f578
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.speedModifier = speed;
|
this.speedModifier = speed;
|
||||||
@@ -257,6 +274,7 @@ public abstract class PathNavigation {
|
@@ -274,6 +292,7 @@ public abstract class PathNavigation {
|
||||||
if (this.hasDelayedRecomputation) {
|
if (this.hasDelayedRecomputation) {
|
||||||
this.recomputePath();
|
this.recomputePath();
|
||||||
}
|
}
|
||||||
@@ -822,17 +820,15 @@ index 544920a31b649985333f82beafa94a3392f5853e..05715fa17caf8d8eece85b7ad752f578
|
|||||||
|
|
||||||
if (!this.isDone()) {
|
if (!this.isDone()) {
|
||||||
if (this.canUpdatePath()) {
|
if (this.canUpdatePath()) {
|
||||||
@@ -282,7 +300,9 @@ public abstract class PathNavigation {
|
@@ -300,6 +319,7 @@ public abstract class PathNavigation {
|
||||||
return this.level.getBlockState(blockPos.below()).isAir() ? pos.y : WalkNodeEvaluator.getFloorLevel(this.level, blockPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ @SuppressWarnings("DataFlowIssue") // Plazma - Process pathfinding asynchronously
|
|
||||||
protected void followThePath() {
|
protected void followThePath() {
|
||||||
+ if (!this.path.isProcessed()) return; // Plazma - Process pathfinding asynchronously
|
+ if (!this.path.isProcessed()) return; // Plazma - Process pathfinding asynchronously
|
||||||
Vec3 vec3 = this.getTempMobPos();
|
Vec3 vec3 = this.getTempMobPos();
|
||||||
this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F;
|
this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F;
|
||||||
Vec3i vec3i = this.path.getNextNodePos();
|
Vec3i vec3i = this.path.getNextNodePos();
|
||||||
@@ -439,7 +459,7 @@ public abstract class PathNavigation {
|
@@ -456,7 +476,7 @@ public abstract class PathNavigation {
|
||||||
public boolean shouldRecomputePath(BlockPos pos) {
|
public boolean shouldRecomputePath(BlockPos pos) {
|
||||||
if (this.hasDelayedRecomputation) {
|
if (this.hasDelayedRecomputation) {
|
||||||
return false;
|
return false;
|
||||||
@@ -842,10 +838,10 @@ index 544920a31b649985333f82beafa94a3392f5853e..05715fa17caf8d8eece85b7ad752f578
|
|||||||
Vec3 vec3 = new Vec3(((double)node.x + this.mob.getX()) / 2.0, ((double)node.y + this.mob.getY()) / 2.0, ((double)node.z + this.mob.getZ()) / 2.0);
|
Vec3 vec3 = new Vec3(((double)node.x + this.mob.getX()) / 2.0, ((double)node.y + this.mob.getY()) / 2.0, ((double)node.z + this.mob.getZ()) / 2.0);
|
||||||
return pos.closerToCenterThan(vec3, (double)(this.path.getNodeCount() - this.path.getNextNodeIndex()));
|
return pos.closerToCenterThan(vec3, (double)(this.path.getNodeCount() - this.path.getNextNodeIndex()));
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||||
index ce7398a617abe6e800c1e014b3ac5c970eb15c8a..8e9a00ee90f97d2684f72eca5006568aa2a858da 100644
|
index 943c9944ae17fa7cd72e437cce61beaf3fc9505e..77c10a3e9570f53ce73dacb39cb86a00202e6ce6 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||||
@@ -15,12 +15,26 @@ public class WaterBoundPathNavigation extends PathNavigation {
|
@@ -15,11 +15,23 @@ public class WaterBoundPathNavigation extends PathNavigation {
|
||||||
super(entity, world);
|
super(entity, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,19 +855,17 @@ index ce7398a617abe6e800c1e014b3ac5c970eb15c8a..8e9a00ee90f97d2684f72eca5006568a
|
|||||||
+ evaluator.setCanWalkOverFences(features.canWalkOverFences());
|
+ evaluator.setCanWalkOverFences(features.canWalkOverFences());
|
||||||
+ return evaluator;
|
+ return evaluator;
|
||||||
+ };
|
+ };
|
||||||
|
+ // Plazma end - Process pathfinding asynchronously
|
||||||
+
|
+
|
||||||
@Override
|
@Override
|
||||||
protected PathFinder createPathFinder(int range) {
|
protected PathFinder createPathFinder(int range) {
|
||||||
this.allowBreaching = this.mob.getType() == EntityType.DOLPHIN;
|
this.allowBreaching = this.mob.getType() == EntityType.DOLPHIN;
|
||||||
this.nodeEvaluator = new SwimNodeEvaluator(this.allowBreaching);
|
this.nodeEvaluator = new SwimNodeEvaluator(this.allowBreaching);
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
- this.nodeEvaluator.setCanPassDoors(false);
|
||||||
+ return new PathFinder(this.nodeEvaluator, range, GENERATOR);
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) return new PathFinder(this.nodeEvaluator, range, GENERATOR); // Plazma - Process pathfinding asynchronously
|
||||||
return new PathFinder(this.nodeEvaluator, range);
|
return new PathFinder(this.nodeEvaluator, range);
|
||||||
}
|
}
|
||||||
+ // Plazma end - Process pathfinding asynchronously
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canUpdatePath() {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||||
index 9104d7010bda6f9f73b478c11490ef9c53f76da2..a53950a6e4cb2e672b6f130461fa630643e3535f 100644
|
index 9104d7010bda6f9f73b478c11490ef9c53f76da2..a53950a6e4cb2e672b6f130461fa630643e3535f 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||||
@@ -903,10 +897,10 @@ index 9104d7010bda6f9f73b478c11490ef9c53f76da2..a53950a6e4cb2e672b6f130461fa6306
|
|||||||
// Paper end - optimise POI access
|
// Paper end - optimise POI access
|
||||||
if (path != null && path.canReach()) {
|
if (path != null && path.canReach()) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
index 9a6ec5e465684be7f0d54b1f7e66bdf52603e442..d1a31e04899e3bce3f884f60916abd4e25dd3afd 100644
|
index ba0b72e648fad219d7b42f5d489b53ec41046826..d83f75719a3be1b5b2c544d89b63a4df420c73d2 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
@@ -1147,7 +1147,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
@@ -1243,7 +1243,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||||
} else {
|
} else {
|
||||||
Bee.this.pathfindRandomlyTowards(Bee.this.hivePos);
|
Bee.this.pathfindRandomlyTowards(Bee.this.hivePos);
|
||||||
}
|
}
|
||||||
@@ -915,7 +909,7 @@ index 9a6ec5e465684be7f0d54b1f7e66bdf52603e442..d1a31e04899e3bce3f884f60916abd4e
|
|||||||
boolean flag = this.pathfindDirectlyTowards(Bee.this.hivePos);
|
boolean flag = this.pathfindDirectlyTowards(Bee.this.hivePos);
|
||||||
|
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
@@ -1209,7 +1209,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
@@ -1302,7 +1302,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||||
} else {
|
} else {
|
||||||
Path pathentity = Bee.this.navigation.getPath();
|
Path pathentity = Bee.this.navigation.getPath();
|
||||||
|
|
||||||
@@ -925,10 +919,10 @@ index 9a6ec5e465684be7f0d54b1f7e66bdf52603e442..d1a31e04899e3bce3f884f60916abd4e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||||
index 651f30b4fb02dc03fabad34b62d7d86fa0889754..2fb5e4fc7422c81c67a026143c92f5e787d864fb 100644
|
index 05e5bb907edb77f2479b29d6e4a15ae446ab0620..963e55584c741a3a3f903f465d897c7ecbf5cd4d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||||
@@ -491,11 +491,25 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
@@ -508,9 +508,23 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||||
return nodeType != PathType.WATER_BORDER && super.canCutCorner(nodeType);
|
return nodeType != PathType.WATER_BORDER && super.canCutCorner(nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -942,36 +936,34 @@ index 651f30b4fb02dc03fabad34b62d7d86fa0889754..2fb5e4fc7422c81c67a026143c92f5e7
|
|||||||
+ evaluator.setCanFloat(features.canFloat());
|
+ evaluator.setCanFloat(features.canFloat());
|
||||||
+ return evaluator;
|
+ return evaluator;
|
||||||
+ };
|
+ };
|
||||||
|
+ // Plazma end - Process pathfinding asynchronously
|
||||||
+
|
+
|
||||||
@Override
|
@Override
|
||||||
protected PathFinder createPathFinder(int range) {
|
protected PathFinder createPathFinder(int range) {
|
||||||
this.nodeEvaluator = new Frog.FrogNodeEvaluator(true);
|
this.nodeEvaluator = new Frog.FrogNodeEvaluator(true);
|
||||||
this.nodeEvaluator.setCanPassDoors(true);
|
+ this.nodeEvaluator.setCanPassDoors(true);
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) return new PathFinder(this.nodeEvaluator, range, GENERATOR); // Plazma - Process pathfinding asynchronously
|
||||||
+ return new PathFinder(this.nodeEvaluator, range, GENERATOR);
|
|
||||||
return new PathFinder(this.nodeEvaluator, range);
|
return new PathFinder(this.nodeEvaluator, range);
|
||||||
}
|
}
|
||||||
+ // Plazma end - Process pathfinding asynchronously
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||||
index 94de51bf9acb32421838ffe54602310f0263b3c4..1afa876e6abac59320c10d37ec8664db1af751b2 100644
|
index 902b4aff751a0f2a4fb8569eb2d88b7ceec7c40f..3235ea771c58ce9c09457a812416346341375613 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
--- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||||
@@ -296,7 +296,7 @@ public class Drowned extends Zombie implements RangedAttackMob {
|
@@ -309,7 +309,7 @@ public class Drowned extends Zombie implements RangedAttackMob {
|
||||||
|
|
||||||
protected boolean closeToNextPos() {
|
protected boolean closeToNextPos() {
|
||||||
Path pathentity = this.getNavigation().getPath();
|
Path path = this.getNavigation().getPath();
|
||||||
|
- if (path != null) {
|
||||||
- if (pathentity != null) {
|
+ if (path != null && path.isProcessed()) { // Plazma - Process pathfinding asynchronously
|
||||||
+ if (pathentity != null && pathentity.isProcessed()) { // Plazma - Process pathfinding asynchronously
|
BlockPos blockPos = path.getTarget();
|
||||||
BlockPos blockposition = pathentity.getTarget();
|
if (blockPos != null) {
|
||||||
|
double d = this.distanceToSqr((double)blockPos.getX(), (double)blockPos.getY(), (double)blockPos.getZ());
|
||||||
if (blockposition != null) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Strider.java b/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Strider.java b/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||||
index 70650cc6f76bed79a31a9e8c86205910994a920f..ca521f6ddaf898f17473e9b87e302ddaf9f30380 100644
|
index 1cee20de1b691a92bee625a877e0ee9769e30b0b..ec871c81817ee82fa7b4ff929693b5ba045d35fb 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
--- a/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||||
@@ -610,10 +610,23 @@ public class Strider extends Animal implements ItemSteerable, Saddleable {
|
@@ -613,9 +613,23 @@ public class Strider extends Animal implements ItemSteerable, Saddleable {
|
||||||
super(entity, world);
|
super(entity, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -990,19 +982,19 @@ index 70650cc6f76bed79a31a9e8c86205910994a920f..ca521f6ddaf898f17473e9b87e302dda
|
|||||||
@Override
|
@Override
|
||||||
protected PathFinder createPathFinder(int range) {
|
protected PathFinder createPathFinder(int range) {
|
||||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||||
this.nodeEvaluator.setCanPassDoors(true);
|
+ this.nodeEvaluator.setCanPassDoors(true);
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) return new PathFinder(this.nodeEvaluator, range, GENERATOR); // Plazma - Process pathfinding asynchronously
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) return new PathFinder(this.nodeEvaluator, range, GENERATOR); // Plazma - Process pathfinding asynchronously
|
||||||
return new PathFinder(this.nodeEvaluator, range);
|
return new PathFinder(this.nodeEvaluator, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||||
index c0398f21cb2ecc9e07f01163a4432a603ff26f03..78a5631753e5bdc16b786ac6951c8d39c4337767 100644
|
index 771e1b5ecc1803079bbb9e4233c616cb3075470e..839a5550a6d613abf4567b32b5f1a04700d6ccf4 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||||
@@ -634,6 +634,15 @@ public class Warden extends Monster implements VibrationSystem {
|
@@ -637,6 +637,15 @@ public class Warden extends Monster implements VibrationSystem {
|
||||||
|
@Override
|
||||||
protected PathFinder createPathFinder(int range) {
|
protected PathFinder createPathFinder(int range) {
|
||||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||||
this.nodeEvaluator.setCanPassDoors(true);
|
|
||||||
+ // Plazma start - Process pathfinding asynchonously
|
+ // Plazma start - Process pathfinding asynchonously
|
||||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled)
|
||||||
+ return new PathFinder(this.nodeEvaluator, range, GroundPathNavigation.GENERATOR) {
|
+ return new PathFinder(this.nodeEvaluator, range, GroundPathNavigation.GENERATOR) {
|
||||||
@@ -1037,10 +1029,10 @@ index d9d0fff9962131808d54cca20f209df50b8e4af1..420dd323790e72aa12c942d31a94bcb8
|
|||||||
public void write(FriendlyByteBuf buf) {
|
public void write(FriendlyByteBuf buf) {
|
||||||
buf.writeCollection(this.targetNodes, (bufx, node) -> node.writeToStream(bufx));
|
buf.writeCollection(this.targetNodes, (bufx, node) -> node.writeToStream(bufx));
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
index 404080976208c30e9e95e5bee47c2a749e709a45..e31ee7508a1af51bec628141c3a153997dc75672 100644
|
index cc7d94144e39f7dace7b569b4567def98396e8f9..95e71c471904fc54003180632dc85398ae06d241 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
@@ -16,6 +16,7 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
@@ -17,6 +17,7 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
import net.minecraft.util.profiling.metrics.MetricCategory;
|
import net.minecraft.util.profiling.metrics.MetricCategory;
|
||||||
import net.minecraft.world.entity.Mob;
|
import net.minecraft.world.entity.Mob;
|
||||||
import net.minecraft.world.level.PathNavigationRegion;
|
import net.minecraft.world.level.PathNavigationRegion;
|
||||||
@@ -1048,49 +1040,36 @@ index 404080976208c30e9e95e5bee47c2a749e709a45..e31ee7508a1af51bec628141c3a15399
|
|||||||
|
|
||||||
public class PathFinder {
|
public class PathFinder {
|
||||||
private static final float FUDGING = 1.5F;
|
private static final float FUDGING = 1.5F;
|
||||||
@@ -24,91 +25,138 @@ public class PathFinder {
|
@@ -25,8 +26,20 @@ public class PathFinder {
|
||||||
public final NodeEvaluator nodeEvaluator;
|
public final NodeEvaluator nodeEvaluator;
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private final BinaryHeap openSet = new BinaryHeap();
|
private final BinaryHeap openSet = new BinaryHeap();
|
||||||
+ // Plazma start - Process pathfinding asynchronously
|
+ // Plazma start - Process pathfinding asynchronously
|
||||||
|
+ public static boolean ASYNC = false;
|
||||||
+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger();
|
+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger();
|
||||||
+ private final @Nullable NodeEvaluatorGenerator evaluatorGenerator;
|
+ private final @Nullable NodeEvaluatorGenerator evaluatorGenerator;
|
||||||
|
+ // Plazma end - Process pathfinding asynchronously
|
||||||
|
|
||||||
public PathFinder(NodeEvaluator pathNodeMaker, int range) {
|
public PathFinder(NodeEvaluator pathNodeMaker, int range) {
|
||||||
|
+ // Plazma start - Process pathfinding asynchronously
|
||||||
+ this(pathNodeMaker, range, null);
|
+ this(pathNodeMaker, range, null);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public PathFinder(NodeEvaluator pathNodeMaker, int range, @Nullable NodeEvaluatorGenerator evaluatorGenerator) {
|
+ public PathFinder(NodeEvaluator pathNodeMaker, int range, @Nullable NodeEvaluatorGenerator evaluatorGenerator) {
|
||||||
|
+ this.evaluatorGenerator = evaluatorGenerator;
|
||||||
|
+ // Plazma end - Process pathfinding asynchronously
|
||||||
this.nodeEvaluator = pathNodeMaker;
|
this.nodeEvaluator = pathNodeMaker;
|
||||||
this.maxVisitedNodes = range;
|
this.maxVisitedNodes = range;
|
||||||
+ this.evaluatorGenerator = evaluatorGenerator;
|
|
||||||
}
|
}
|
||||||
|
@@ -37,100 +50,48 @@ public class PathFinder {
|
||||||
|
|
||||||
+ @SuppressWarnings("ConstantValue")
|
|
||||||
@Nullable
|
@Nullable
|
||||||
- public Path findPath(PathNavigationRegion world, Mob mob, Set<BlockPos> positions, float followRange, int distance, float rangeMultiplier) {
|
public Path findPath(PathNavigationRegion world, Mob mob, Set<BlockPos> positions, float followRange, int distance, float rangeMultiplier) {
|
||||||
- this.openSet.clear();
|
- this.openSet.clear();
|
||||||
- this.nodeEvaluator.prepare(world, mob);
|
- this.nodeEvaluator.prepare(world, mob);
|
||||||
- Node node = this.nodeEvaluator.getStart();
|
- Node node = this.nodeEvaluator.getStart();
|
||||||
+ public Path findPath(
|
- if (node == null) {
|
||||||
+ PathNavigationRegion world,
|
- return null;
|
||||||
+ Mob mob,
|
|
||||||
+ Set<BlockPos> positions,
|
|
||||||
+ float followRange,
|
|
||||||
+ int distance,
|
|
||||||
+ float rangeMultiplier
|
|
||||||
+ ) {
|
|
||||||
+ if (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) this.openSet.clear();
|
|
||||||
+ NodeEvaluator evaluator = this.evaluatorGenerator == null
|
|
||||||
+ ? this.nodeEvaluator
|
|
||||||
+ : NodeEvaluatorCache.take(this.evaluatorGenerator, this.nodeEvaluator);
|
|
||||||
+
|
|
||||||
+ evaluator.prepare(world, mob);
|
|
||||||
+ Node node = evaluator.getStart();
|
|
||||||
+
|
|
||||||
if (node == null) {
|
|
||||||
+ NodeEvaluatorCache.remove(evaluator);
|
|
||||||
return null;
|
|
||||||
- } else {
|
- } else {
|
||||||
- // Paper start - Perf: remove streams and optimize collection
|
- // Paper start - Perf: remove streams and optimize collection
|
||||||
- List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
- List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
||||||
@@ -1098,112 +1077,66 @@ index 404080976208c30e9e95e5bee47c2a749e709a45..e31ee7508a1af51bec628141c3a15399
|
|||||||
- map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos));
|
- map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos));
|
||||||
- }
|
- }
|
||||||
- // Paper end - Perf: remove streams and optimize collection
|
- // Paper end - Perf: remove streams and optimize collection
|
||||||
- Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier);
|
- Path path = this.findPath(node, map, followRange, distance, rangeMultiplier);
|
||||||
- this.nodeEvaluator.done();
|
- this.nodeEvaluator.done();
|
||||||
- return path;
|
- return path;
|
||||||
}
|
- }
|
||||||
+
|
- }
|
||||||
+ List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
-
|
||||||
+ for (final BlockPos pos : positions)
|
- @Nullable
|
||||||
+ map.add(new java.util.AbstractMap.SimpleEntry<>(evaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos));
|
- // Paper start - Perf: remove streams and optimize collection
|
||||||
+
|
- private Path findPath(Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||||
+ if (this.evaluatorGenerator == null) {
|
- ProfilerFiller profilerFiller = Profiler.get();
|
||||||
+ NodeEvaluatorCache.remove(evaluator);
|
- profilerFiller.push("find_path");
|
||||||
+ return this.findPath(node, map, followRange, distance, rangeMultiplier);
|
- profilerFiller.markForCharting(MetricCategory.PATH_FINDING);
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return new AsyncPath(
|
|
||||||
+ Lists.newArrayList(),
|
|
||||||
+ positions,
|
|
||||||
+ () -> this.processPath(evaluator, node, map, followRange, distance, rangeMultiplier),
|
|
||||||
+ () -> {
|
|
||||||
+ evaluator.done();
|
|
||||||
+ NodeEvaluatorCache.returnEvaluator(evaluator);
|
|
||||||
+ }
|
|
||||||
+ );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
// Paper start - Perf: remove streams and optimize collection
|
|
||||||
- private Path findPath(ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
|
||||||
- //profiler.push("find_path"); // Purpur
|
|
||||||
- //profiler.markForCharting(MetricCategory.PATH_FINDING); // Purpur
|
|
||||||
- // Set<Target> set = positions.keySet();
|
- // Set<Target> set = positions.keySet();
|
||||||
+ private Path findPath(
|
- startNode.g = 0.0F;
|
||||||
+ Node startNode,
|
- startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection
|
||||||
+ List<Map.Entry<Target, BlockPos>> positions,
|
- startNode.f = startNode.h;
|
||||||
+ float followRange,
|
- this.openSet.clear();
|
||||||
+ int distance,
|
- this.openSet.insert(startNode);
|
||||||
+ float rangeMultiplier
|
|
||||||
+ ) {
|
|
||||||
+ try {
|
|
||||||
+ return this.processPath(this.nodeEvaluator, startNode, positions, followRange, distance, rangeMultiplier);
|
|
||||||
+ } catch (Exception e) {
|
|
||||||
+ LOGGER.error("Failed to process path", e);
|
|
||||||
+ return null;
|
|
||||||
+ } finally {
|
|
||||||
+ this.nodeEvaluator.done();
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @SuppressWarnings("DataFlowIssue")
|
|
||||||
+ @org.jetbrains.annotations.NotNull
|
|
||||||
+ private synchronized Path processPath(
|
|
||||||
+ NodeEvaluator nodeEvaluator,
|
|
||||||
+ Node startNode,
|
|
||||||
+ List<Map.Entry<Target, BlockPos>> positions,
|
|
||||||
+ float followRange,
|
|
||||||
+ int distance,
|
|
||||||
+ float rangeMultiplier
|
|
||||||
+ ) {
|
|
||||||
+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty());
|
|
||||||
startNode.g = 0.0F;
|
|
||||||
startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection
|
|
||||||
startNode.f = startNode.h;
|
|
||||||
this.openSet.clear();
|
|
||||||
this.openSet.insert(startNode);
|
|
||||||
- // Set<Node> set2 = ImmutableSet.of(); // Paper - unused - diff on change
|
- // Set<Node> set2 = ImmutableSet.of(); // Paper - unused - diff on change
|
||||||
+
|
- int i = 0;
|
||||||
int i = 0;
|
- List<Map.Entry<Target, BlockPos>> entryList = Lists.newArrayListWithExpectedSize(positions.size()); // Paper - optimize collection
|
||||||
List<Map.Entry<Target, BlockPos>> entryList = Lists.newArrayListWithExpectedSize(positions.size()); // Paper - optimize collection
|
- int j = (int)((float)this.maxVisitedNodes * rangeMultiplier);
|
||||||
int j = (int)((float)this.maxVisitedNodes * rangeMultiplier);
|
+ if (ASYNC) this.openSet.clear();
|
||||||
|
|
||||||
while (!this.openSet.isEmpty()) {
|
- while (!this.openSet.isEmpty()) {
|
||||||
- if (++i >= j) {
|
- if (++i >= j) {
|
||||||
- break;
|
- break;
|
||||||
- }
|
- }
|
||||||
+ if (++i >= j) break;
|
+ NodeEvaluator evaluator = this.evaluatorGenerator == null ? this.nodeEvaluator : NodeEvaluatorCache.take(this.evaluatorGenerator, this.nodeEvaluator);
|
||||||
|
+ evaluator.prepare(world, mob);
|
||||||
|
|
||||||
Node node = this.openSet.pop();
|
- Node node = this.openSet.pop();
|
||||||
node.closed = true;
|
- node.closed = true;
|
||||||
|
+ Node node = evaluator.getStart();
|
||||||
|
+ if ( node == null ) {
|
||||||
|
+ NodeEvaluatorCache.remove(evaluator);
|
||||||
|
+ return null; // diff on change
|
||||||
|
+ }
|
||||||
|
|
||||||
- // Paper start - optimize collection
|
- // Paper start - optimize collection
|
||||||
- for (int i1 = 0; i1 < positions.size(); i1++) {
|
- for (int i1 = 0; i1 < positions.size(); i1++) {
|
||||||
- final Map.Entry<Target, BlockPos> entry = positions.get(i1);
|
- final Map.Entry<Target, BlockPos> entry = positions.get(i1);
|
||||||
+ for (final Map.Entry<Target, BlockPos> entry : positions) {
|
- Target target = entry.getKey();
|
||||||
Target target = entry.getKey();
|
|
||||||
- if (node.distanceManhattan(target) <= (float)distance) {
|
- if (node.distanceManhattan(target) <= (float)distance) {
|
||||||
+ if (node.distanceManhattan(target) <= (float) distance) {
|
- target.setReached();
|
||||||
target.setReached();
|
- entryList.add(entry);
|
||||||
entryList.add(entry);
|
|
||||||
- // Paper end - Perf: remove streams and optimize collection
|
- // Paper end - Perf: remove streams and optimize collection
|
||||||
}
|
- }
|
||||||
}
|
- }
|
||||||
|
+ List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
||||||
|
+ for (final BlockPos pos : positions)
|
||||||
|
+ map.add(new java.util.AbstractMap.SimpleEntry<>(evaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos));
|
||||||
|
|
||||||
- if (!entryList.isEmpty()) { // Paper - Perf: remove streams and optimize collection; rename
|
- if (!entryList.isEmpty()) { // Paper - Perf: remove streams and optimize collection; rename
|
||||||
- break;
|
- break;
|
||||||
- }
|
- }
|
||||||
+ if (!entryList.isEmpty()) break;
|
+ if (this.evaluatorGenerator == null) {
|
||||||
+ if (node.distanceTo(startNode) >= followRange) continue;
|
+ NodeEvaluatorCache.remove(evaluator);
|
||||||
+
|
+ return this.findPath(node, map, followRange, distance, rangeMultiplier);
|
||||||
+ int k = nodeEvaluator.getNeighbors(this.neighbors, node);
|
+ }
|
||||||
+
|
|
||||||
+ for (int l = 0; l < k; l++) {
|
|
||||||
+ Node node2 = this.neighbors[l];
|
|
||||||
+ float f = this.distance(node, node2);
|
|
||||||
+ node2.walkedDistance = node.walkedDistance + f;
|
|
||||||
+ float g = node.g + f + node2.costMalus;
|
|
||||||
+ if (node2.walkedDistance >= followRange || (node2.inOpenSet() && g >= node2.g)) continue;
|
|
||||||
|
|
||||||
- if (!(node.distanceTo(startNode) >= followRange)) {
|
- if (!(node.distanceTo(startNode) >= followRange)) {
|
||||||
- int k = this.nodeEvaluator.getNeighbors(this.neighbors, node);
|
- int k = this.nodeEvaluator.getNeighbors(this.neighbors, node);
|
||||||
@@ -1224,26 +1157,124 @@ index 404080976208c30e9e95e5bee47c2a749e709a45..e31ee7508a1af51bec628141c3a15399
|
|||||||
- this.openSet.insert(node2);
|
- this.openSet.insert(node2);
|
||||||
- }
|
- }
|
||||||
- }
|
- }
|
||||||
|
- }
|
||||||
|
+ return new AsyncPath(
|
||||||
|
+ Lists.newArrayList(),
|
||||||
|
+ positions,
|
||||||
|
+ () -> this.processPath(evaluator, node, map, followRange, distance, rangeMultiplier),
|
||||||
|
+ () -> {
|
||||||
|
+ evaluator.done();
|
||||||
|
+ NodeEvaluatorCache.returnEvaluator(evaluator);
|
||||||
|
}
|
||||||
|
- }
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- // Paper start - Perf: remove streams and optimize collection
|
||||||
|
- Path best = null;
|
||||||
|
- boolean entryListIsEmpty = entryList.isEmpty();
|
||||||
|
- Comparator<Path> comparator = entryListIsEmpty ? Comparator.comparingInt(Path::getNodeCount)
|
||||||
|
- : Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount);
|
||||||
|
- for (Map.Entry<Target, BlockPos> entry : entryListIsEmpty ? positions : entryList) {
|
||||||
|
- Path path = this.reconstructPath(entry.getKey().getBestNode(), entry.getValue(), !entryListIsEmpty);
|
||||||
|
- if (best == null || comparator.compare(path, best) < 0)
|
||||||
|
- best = path;
|
||||||
|
+ @Nullable
|
||||||
|
+ // Paper start - Perf: remove streams and optimize collection
|
||||||
|
+ private Path findPath(Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||||
|
+ try {
|
||||||
|
+ return this.processPath(this.nodeEvaluator, startNode, positions, followRange, distance, rangeMultiplier);
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ LOGGER.error("Failed to process path", e);
|
||||||
|
+ return null;
|
||||||
|
+ } finally {
|
||||||
|
+ this.nodeEvaluator.done();
|
||||||
|
}
|
||||||
|
- profilerFiller.pop();
|
||||||
|
- return best;
|
||||||
|
- // Paper end - Perf: remove streams and optimize collection
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float distance(Node a, Node b) {
|
||||||
|
@@ -164,4 +125,78 @@ public class PathFinder {
|
||||||
|
|
||||||
|
return new Path(list, target, reachesTarget);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ private Path processPath(NodeEvaluator evaluator, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||||
|
+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty());
|
||||||
|
+
|
||||||
|
+ startNode.g = 0.0F;
|
||||||
|
+ startNode.h = this.getBestH(startNode, positions);
|
||||||
|
+ startNode.f = startNode.h;
|
||||||
|
+
|
||||||
|
+ this.openSet.clear();
|
||||||
|
+ this.openSet.insert(startNode);
|
||||||
|
+
|
||||||
|
+ int i = 0;
|
||||||
|
+ int j = (int) (this.maxVisitedNodes * rangeMultiplier);
|
||||||
|
+ List<Map.Entry<Target, BlockPos>> entryList = Lists.newArrayListWithExpectedSize(positions.size());
|
||||||
|
+
|
||||||
|
+ while (!this.openSet.isEmpty()) {
|
||||||
|
+ if (++i >= j) break;
|
||||||
|
+
|
||||||
|
+ Node node = this.openSet.pop();
|
||||||
|
+ node.closed = true;
|
||||||
|
+
|
||||||
|
+ for (final Map.Entry<Target, BlockPos> entry : positions) {
|
||||||
|
+ Target target = entry.getKey();
|
||||||
|
+ if (node.distanceManhattan(target) > distance) continue;
|
||||||
|
+
|
||||||
|
+ target.setReached();
|
||||||
|
+ entryList.add(entry);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!entryList.isEmpty()) break;
|
||||||
|
+ if (node.distanceTo(startNode) >= followRange) continue;
|
||||||
|
+
|
||||||
|
+ int k = evaluator.getNeighbors(this.neighbors, node);
|
||||||
|
+ for (int l = 0; l < k; l++) {
|
||||||
|
+ Node node2 = this.neighbors[l];
|
||||||
|
+
|
||||||
|
+ float f = this.distance(node, node2);
|
||||||
|
+ float g = node.g + f + node2.costMalus;
|
||||||
|
+
|
||||||
|
+ node2.walkedDistance = node.walkedDistance + f;
|
||||||
|
+ if (node2.walkedDistance >= followRange && !(!node2.inOpenSet() || g < node2.g)) continue;
|
||||||
|
+
|
||||||
+ node2.cameFrom = node;
|
+ node2.cameFrom = node;
|
||||||
+ node2.g = g;
|
+ node2.g = g;
|
||||||
+ node2.h = this.getBestH(node2, positions) * 1.5F; // Paper - Perf: remove streams and optimize collection
|
+ node2.h = this.getBestH(node2, positions) * 1.5F;
|
||||||
|
+
|
||||||
+ if (node2.inOpenSet()) {
|
+ if (node2.inOpenSet()) {
|
||||||
+ this.openSet.changeCost(node2, node2.g + node2.h);
|
+ this.openSet.changeCost(node2, node2.g + node2.h);
|
||||||
+ continue;
|
+ continue;
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ node2.f = node2.g + node2.h;
|
+ node2.f = node2.g + node2.h;
|
||||||
+ this.openSet.insert(node2);
|
+ this.openSet.insert(node2);
|
||||||
}
|
+ }
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
@@ -126,6 +174,7 @@ public class PathFinder {
|
+ Path best = null;
|
||||||
return best;
|
+ boolean isEmpty = entryList.isEmpty();
|
||||||
// Paper end - Perf: remove streams and optimize collection
|
+
|
||||||
}
|
+ Comparator<Path> comparator = isEmpty
|
||||||
+ // Plazma end - Process pathfinding asynchronously
|
+ ? Comparator.comparingInt(Path::getNodeCount)
|
||||||
|
+ : Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount);
|
||||||
protected float distance(Node a, Node b) {
|
+
|
||||||
return a.distanceTo(b);
|
+ for (final Map.Entry<Target, BlockPos> entry : isEmpty ? positions : entryList) {
|
||||||
|
+ Path path = this.reconstructPath(entry.getKey().getBestNode(), entry.getValue(), !isEmpty);
|
||||||
|
+ if (best != null && comparator.compare(path, best) >= 0) continue;
|
||||||
|
+
|
||||||
|
+ best = path;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return best;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||||
index 6308822f819d7cb84c8070c8a7eec1a3f822114b..370540e48a5fd5693bf956ffbddccca58a1482f8 100644
|
index 6308822f819d7cb84c8070c8a7eec1a3f822114b..370540e48a5fd5693bf956ffbddccca58a1482f8 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||||
@@ -1270,12 +1301,12 @@ index 1c83926923f50fb4da1a83dc91614c20a831555f..aec2d0f9a957be65d031957dbff874d8
|
|||||||
|
|
||||||
Command.broadcastCommandMessage(sender, text("Successfully reloaded Plazma configuration files.", NamedTextColor.GREEN));
|
Command.broadcastCommandMessage(sender, text("Successfully reloaded Plazma configuration files.", NamedTextColor.GREEN));
|
||||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
index ae6b4ee0add2de0b7568424abeab1bd441653bcb..d0a1b97bacf9978b4955b1c2c4502c2c1312f1d4 100644
|
index 8914159c17b3c8b0114e88c5317df5f17b05e5d6..92de32ee00bc9c4e8750773bca95a9cf5fbae067 100644
|
||||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
@@ -62,6 +62,26 @@ public class GlobalConfiguration extends ConfigurationPart {
|
@@ -86,6 +86,26 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
boolean skipSqrWhenNoDeltaChanges = OPTIMIZE;
|
public class Entity extends ConfigurationPart {
|
||||||
public boolean spookyOptimize = OPTIMIZE;
|
|
||||||
|
|
||||||
+ public AsyncPathProcess asyncPathProcess;
|
+ public AsyncPathProcess asyncPathProcess;
|
||||||
+ public class AsyncPathProcess extends ConfigurationPart {
|
+ public class AsyncPathProcess extends ConfigurationPart {
|
||||||
@@ -1299,4 +1330,4 @@ index ae6b4ee0add2de0b7568424abeab1bd441653bcb..d0a1b97bacf9978b4955b1c2c4502c2c
|
|||||||
+
|
+
|
||||||
@PostProcess
|
@PostProcess
|
||||||
public void post() {
|
public void post() {
|
||||||
net.minecraft.server.level.ServerEntity.skipSqrWhenNoDeltaChanges = this.skipSqrWhenNoDeltaChanges;
|
}
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Sat, 26 Oct 2024 13:42:26 +0900
|
||||||
|
Subject: [PATCH] Implement alternative noise chunk generator
|
||||||
|
|
||||||
|
Based on Steveplays28/noisium.
|
||||||
|
Copyright (C) 2024 Darion Spaargaren, Licensed under GPL v3.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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 e4ae25c83ab9dd1aaa530a5456275ef63cdb8511..03a5effa6f0ef4d5c46a03a39cf336493873cfea 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||||
|
@@ -19,9 +19,9 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
|
public static final int SECTION_HEIGHT = 16;
|
||||||
|
public static final int SECTION_SIZE = 4096;
|
||||||
|
public static final int BIOME_CONTAINER_BITS = 2;
|
||||||
|
- short nonEmptyBlockCount; // Paper - package private
|
||||||
|
- private short tickingBlockCount;
|
||||||
|
- private short tickingFluidCount;
|
||||||
|
+ public short nonEmptyBlockCount; // Paper - package private // Plazma -> public
|
||||||
|
+ public short tickingBlockCount; // Plazma - private -> public
|
||||||
|
+ public short tickingFluidCount; // Plazma - private -> public
|
||||||
|
public final PalettedContainer<BlockState> states;
|
||||||
|
private PalettedContainer<Holder<Biome>> biomes; // CraftBukkit - read/write
|
||||||
|
|
||||||
|
@@ -35,8 +35,8 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
|
|
||||||
|
private boolean isClient;
|
||||||
|
private static final short CLIENT_FORCED_SPECIAL_COLLIDING_BLOCKS = (short)9999;
|
||||||
|
- private short specialCollidingBlocks;
|
||||||
|
- private final ca.spottedleaf.moonrise.common.list.ShortList tickingBlocks = new ca.spottedleaf.moonrise.common.list.ShortList();
|
||||||
|
+ public short specialCollidingBlocks; // Plazma - private -> public
|
||||||
|
+ public final ca.spottedleaf.moonrise.common.list.ShortList tickingBlocks = new ca.spottedleaf.moonrise.common.list.ShortList(); // Plazma - private -> public
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean moonrise$hasSpecialCollidingBlocks() {
|
||||||
|
@@ -309,18 +309,14 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
public void fillBiomesFromNoise(BiomeResolver biomeSupplier, Climate.Sampler sampler, int x, int y, int z) {
|
||||||
|
- PalettedContainer<Holder<Biome>> datapaletteblock = this.biomes.recreate();
|
||||||
|
- boolean flag = true;
|
||||||
|
+ // Plazma start - Optimize noise
|
||||||
|
+ PalettedContainer<Holder<Biome>> block = this.biomes.recreate();
|
||||||
|
|
||||||
|
- for (int l = 0; l < 4; ++l) {
|
||||||
|
- for (int i1 = 0; i1 < 4; ++i1) {
|
||||||
|
- for (int j1 = 0; j1 < 4; ++j1) {
|
||||||
|
- datapaletteblock.getAndSetUnchecked(l, i1, j1, biomeSupplier.getNoiseBiome(x + l, y + i1, z + j1, sampler));
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ for (int dY = 0; dY < 4; ++dY) for (int dZ = 0; dZ < 4; ++dZ) for (int dX = 0; dX < 4; ++dX)
|
||||||
|
+ block.getAndSetUnchecked(dX, dY, dZ, biomeSupplier.getNoiseBiome(x + dX, y + dY, z + dZ, sampler));
|
||||||
|
|
||||||
|
- this.biomes = datapaletteblock;
|
||||||
|
+ this.biomes = block;
|
||||||
|
+ // Plazma end - Optimize noise
|
||||||
|
}
|
||||||
|
|
||||||
|
public LevelChunkSection copy() {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
|
index 8b84bf2272556ac3321cbf16361d7f48a1cc6873..84047336fbd8833cc95bf5afa721f983aee97d4d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
|
@@ -30,7 +30,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||||
|
public final IdMap<T> registry;
|
||||||
|
private final T @org.jetbrains.annotations.Nullable [] presetValues; // Paper - Anti-Xray - Add preset values
|
||||||
|
public volatile PalettedContainer.Data<T> data; // Paper - optimise collisions - public
|
||||||
|
- private final PalettedContainer.Strategy strategy;
|
||||||
|
+ public final PalettedContainer.Strategy strategy; // Plazma - private -> public
|
||||||
|
// private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); // Paper - unused
|
||||||
|
|
||||||
|
public void acquire() {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||||
|
index 0346fd4ab7095d66c0eef5a440afbc7a8ba52466..35b589fa6d53cce957365e1cfcb5cf1978390546 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||||
|
@@ -51,6 +51,7 @@ import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
|
|
||||||
|
public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||||
|
|
||||||
|
+ public static boolean PLAZMA_USE_NOISIUM = false; // Plazma - Optimize noise chunk generation
|
||||||
|
public static final MapCodec<NoiseBasedChunkGenerator> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||||
|
return instance.group(BiomeSource.CODEC.fieldOf("biome_source").forGetter((chunkgeneratorabstract) -> {
|
||||||
|
return chunkgeneratorabstract.biomeSource;
|
||||||
|
@@ -270,6 +271,24 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||||
|
int k = Mth.floorDiv(noisesettings.height(), noisesettings.getCellHeight());
|
||||||
|
|
||||||
|
return k <= 0 ? CompletableFuture.completedFuture(chunk) : CompletableFuture.supplyAsync(() -> {
|
||||||
|
+ // Plazma start - Optimize noise chunk generation
|
||||||
|
+ if (PLAZMA_USE_NOISIUM) {
|
||||||
|
+ int l = chunk.getSectionIndex(k * noisesettings.getCellHeight() - 1 + i);
|
||||||
|
+ int i1 = chunk.getSectionIndex(i);
|
||||||
|
+
|
||||||
|
+ var set = chunk.getSections();
|
||||||
|
+ for (int j1 = l; j1 >= i1; --j1) set[j1].acquire();
|
||||||
|
+
|
||||||
|
+ ChunkAccess ichunkaccess1;
|
||||||
|
+ try {
|
||||||
|
+ ichunkaccess1 = this.doFill(blender, structureAccessor, noiseConfig, chunk, j, k);
|
||||||
|
+ } finally {
|
||||||
|
+ for (int j1 = l; j1 >= i1; --j1) set[j1].release();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return ichunkaccess1;
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - Optimize noise chunk generation
|
||||||
|
int l = chunk.getSectionIndex(k * noisesettings.getCellHeight() - 1 + i);
|
||||||
|
int i1 = chunk.getSectionIndex(i);
|
||||||
|
Set<LevelChunkSection> set = Sets.newHashSet();
|
||||||
|
@@ -377,6 +396,18 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||||
|
|
||||||
|
iblockdata = this.debugPreliminarySurfaceLevel(noisechunk, j4, j3, i5, iblockdata);
|
||||||
|
if (iblockdata != NoiseBasedChunkGenerator.AIR && !SharedConstants.debugVoidTerrain(chunk.getPos())) {
|
||||||
|
+ // Plazma start - Optimize noise
|
||||||
|
+ if (PLAZMA_USE_NOISIUM) {
|
||||||
|
+ var id = chunksection.states.data.palette().idFor(iblockdata);
|
||||||
|
+ chunksection.states.data.storage().getAndSet(chunksection.states.strategy.getIndex(k4, k3, j5), id);
|
||||||
|
+
|
||||||
|
+ ++chunksection.nonEmptyBlockCount;
|
||||||
|
+ if (iblockdata.isRandomlyTicking()) ++chunksection.tickingBlockCount;
|
||||||
|
+ if (iblockdata.getFluidState().isRandomlyTicking()) ++chunksection.tickingFluidCount;
|
||||||
|
+ if (ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isSpecialCollidingBlock(iblockdata)) ++chunksection.specialCollidingBlocks;
|
||||||
|
+ if (chunksection.isRandomlyTicking()) chunksection.tickingBlocks.add((short) (k4 | (k3 << 4) | (j5 << (4+4))));
|
||||||
|
+ } else
|
||||||
|
+ // Plazma end - Optimize noise
|
||||||
|
chunksection.setBlockState(k4, k3, j5, iblockdata, false);
|
||||||
|
heightmap.update(k4, j3, j5, iblockdata);
|
||||||
|
heightmap1.update(k4, j3, j5, iblockdata);
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseSettings.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseSettings.java
|
||||||
|
index 932d1d9bd717b1176f8c82b0cf65d2eb6403ad40..a54a279cbaa30c58df572242ad5cf9786c715b66 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseSettings.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseSettings.java
|
||||||
|
@@ -8,7 +8,7 @@ import net.minecraft.core.QuartPos;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
|
|
||||||
|
-public record NoiseSettings(int minY, int height, int noiseSizeHorizontal, int noiseSizeVertical) {
|
||||||
|
+public record NoiseSettings(int minY, int height, int noiseSizeHorizontal, int noiseSizeVertical, int horizontalCellBlockCount, int verticalCellBlockCount) { // Plazma - Optimize noise
|
||||||
|
public static final Codec<NoiseSettings> CODEC = RecordCodecBuilder.<NoiseSettings>create(
|
||||||
|
instance -> instance.group(
|
||||||
|
Codec.intRange(DimensionType.MIN_Y, DimensionType.MAX_Y).fieldOf("min_y").forGetter(NoiseSettings::minY),
|
||||||
|
@@ -16,7 +16,7 @@ public record NoiseSettings(int minY, int height, int noiseSizeHorizontal, int n
|
||||||
|
Codec.intRange(1, 4).fieldOf("size_horizontal").forGetter(NoiseSettings::noiseSizeHorizontal),
|
||||||
|
Codec.intRange(1, 4).fieldOf("size_vertical").forGetter(NoiseSettings::noiseSizeVertical)
|
||||||
|
)
|
||||||
|
- .apply(instance, NoiseSettings::new)
|
||||||
|
+ .apply(instance, NoiseSettings::create) // Plazma - Optimize noise
|
||||||
|
)
|
||||||
|
.comapFlatMap(NoiseSettings::guardY, Function.identity());
|
||||||
|
protected static final NoiseSettings OVERWORLD_NOISE_SETTINGS = create(-64, 384, 1, 2);
|
||||||
|
@@ -36,7 +36,7 @@ public record NoiseSettings(int minY, int height, int noiseSizeHorizontal, int n
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NoiseSettings create(int minimumY, int height, int horizontalSize, int verticalSize) {
|
||||||
|
- NoiseSettings noiseSettings = new NoiseSettings(minimumY, height, horizontalSize, verticalSize);
|
||||||
|
+ NoiseSettings noiseSettings = new NoiseSettings(minimumY, height, horizontalSize, verticalSize, QuartPos.toBlock(horizontalSize), QuartPos.toBlock(verticalSize)); // Plazma - Optimize noise
|
||||||
|
guardY(noiseSettings).error().ifPresent(error -> {
|
||||||
|
throw new IllegalStateException(error.message());
|
||||||
|
});
|
||||||
|
@@ -44,16 +44,16 @@ public record NoiseSettings(int minY, int height, int noiseSizeHorizontal, int n
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCellHeight() {
|
||||||
|
- return QuartPos.toBlock(this.noiseSizeVertical());
|
||||||
|
+ return this.horizontalCellBlockCount; // Plazma - Optimize noise
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCellWidth() {
|
||||||
|
- return QuartPos.toBlock(this.noiseSizeHorizontal());
|
||||||
|
+ return this.verticalCellBlockCount; // Plazma - Optimize noise
|
||||||
|
}
|
||||||
|
|
||||||
|
public NoiseSettings clampToHeightAccessor(LevelHeightAccessor world) {
|
||||||
|
int i = Math.max(this.minY, world.getMinY());
|
||||||
|
int j = Math.min(this.minY + this.height, world.getMaxY() + 1) - i;
|
||||||
|
- return new NoiseSettings(i, j, this.noiseSizeHorizontal, this.noiseSizeVertical);
|
||||||
|
+ return new NoiseSettings(i, j, this.noiseSizeHorizontal, this.noiseSizeVertical, QuartPos.toBlock(this.noiseSizeHorizontal), QuartPos.toBlock(this.noiseSizeVertical)); // Plazma - Optimize noise
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/material/MaterialRuleList.java b/src/main/java/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||||
|
index 0e6dfe2635ea5f5e410049b05f94f5083b2f18a4..584311a00c5037a6d5bc05b1261969aad1c38a4c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||||
|
@@ -9,12 +9,15 @@ public record MaterialRuleList(NoiseChunk.BlockStateFiller[] materialRuleList) i
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockState calculate(DensityFunction.FunctionContext pos) {
|
||||||
|
- for (NoiseChunk.BlockStateFiller blockStateFiller : this.materialRuleList) {
|
||||||
|
- BlockState blockState = blockStateFiller.calculate(pos);
|
||||||
|
- if (blockState != null) {
|
||||||
|
- return blockState;
|
||||||
|
- }
|
||||||
|
+ // Plazma start - Optimize noise
|
||||||
|
+ //noinspection ForLoopReplaceableByForEach
|
||||||
|
+ for (int i = 0; i < this.materialRuleList.length; i++) {
|
||||||
|
+ BlockState state = this.materialRuleList[i].calculate(pos);
|
||||||
|
+ if (state == null) continue;
|
||||||
|
+
|
||||||
|
+ return state;
|
||||||
|
}
|
||||||
|
+ // Plazma end - Optimize noise
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
index 92de32ee00bc9c4e8750773bca95a9cf5fbae067..fbcbbba15e8f7f8ea812a75d807908925305cb29 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
@@ -61,6 +61,8 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
public WorldGeneration worldgen;
|
||||||
|
public class WorldGeneration extends ConfigurationPart {
|
||||||
|
|
||||||
|
+ boolean useAlternativeNoiseGenerator = OPTIMIZE;
|
||||||
|
+
|
||||||
|
public LavaSea lavaSea;
|
||||||
|
public class LavaSea extends ConfigurationPart {
|
||||||
|
|
||||||
|
@@ -80,6 +82,11 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ @PostProcess
|
||||||
|
+ void post() {
|
||||||
|
+ net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator.PLAZMA_USE_NOISIUM = this.useAlternativeNoiseGenerator;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entity entity;
|
||||||
1266
patches/server/features/0045-Reduce-allocations.patch
Normal file
1266
patches/server/features/0045-Reduce-allocations.patch
Normal file
File diff suppressed because it is too large
Load Diff
236
patches/server/features/0046-Hashed-rcon-password.patch
Normal file
236
patches/server/features/0046-Hashed-rcon-password.patch
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Tue, 5 Nov 2024 18:31:09 +0900
|
||||||
|
Subject: [PATCH] Hashed rcon password
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
|
index 3dd5c7441bb300ca17d717af37edbefb89db4b2f..df367fbb8c582614aaf2087aa37d5e47247af810 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
|
@@ -73,7 +73,6 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
|
public final int queryPort;
|
||||||
|
public final boolean enableRcon;
|
||||||
|
public final int rconPort;
|
||||||
|
- public final String rconPassword;
|
||||||
|
public final boolean hardcore;
|
||||||
|
public final boolean allowNether;
|
||||||
|
public final boolean spawnMonsters;
|
||||||
|
@@ -113,6 +112,25 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
|
|
||||||
|
public final String rconIp; // Paper - Configurable rcon ip
|
||||||
|
|
||||||
|
+ // Plazma start - hashed rcon password
|
||||||
|
+ private final boolean rconHash;
|
||||||
|
+ private final int rconHashIterationCount;
|
||||||
|
+ private final byte[] rconSalt;
|
||||||
|
+ private final String rconPassword;
|
||||||
|
+
|
||||||
|
+ private static final @Nullable javax.crypto.SecretKeyFactory HASH_INSTANCE;
|
||||||
|
+ static {
|
||||||
|
+ @Nullable javax.crypto.SecretKeyFactory factory;
|
||||||
|
+ try {
|
||||||
|
+ factory = javax.crypto.SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512/256");
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ LOGGER.error("Failed to initialize rcon hash instance", e);
|
||||||
|
+ factory = null;
|
||||||
|
+ }
|
||||||
|
+ HASH_INSTANCE = factory;
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - hashed rcon password
|
||||||
|
+
|
||||||
|
// CraftBukkit start
|
||||||
|
public DedicatedServerProperties(Properties properties, OptionSet optionset) {
|
||||||
|
super(properties, optionset);
|
||||||
|
@@ -126,7 +144,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
|
this.queryPort = this.get("query.port", 25565);
|
||||||
|
this.enableRcon = this.get("enable-rcon", false);
|
||||||
|
this.rconPort = this.get("rcon.port", 25575);
|
||||||
|
- this.rconPassword = this.get("rcon.password", "");
|
||||||
|
+ // this.rconPassword = this.get("rcon.password", ""); // Plazma - hashed rcon password
|
||||||
|
this.hardcore = this.get("hardcore", false);
|
||||||
|
this.allowNether = this.get("allow-nether", true);
|
||||||
|
this.spawnMonsters = this.get("spawn-monsters", true);
|
||||||
|
@@ -179,7 +197,82 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
|
final String rconIp = this.getStringRaw("rcon.ip");
|
||||||
|
this.rconIp = rconIp == null ? this.serverIp : rconIp;
|
||||||
|
// Paper end - Configurable rcon ip
|
||||||
|
+
|
||||||
|
+ // Plazma start - hashed rcon password
|
||||||
|
+ this.rconHash = this.get("rcon.hash", false);
|
||||||
|
+ this.rconHashIterationCount = this.get("rcon.hash.iteration-count", Character.MAX_VALUE);
|
||||||
|
+ this.rconSalt = this.rconSalt();
|
||||||
|
+ this.rconPassword = this.rconPassword();
|
||||||
|
+ // Plazma end - hashed rcon password
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Plazma start - hashed rcon password
|
||||||
|
+ private byte[] rconSalt() {
|
||||||
|
+ if (!this.rconHash) return org.plazmamc.plazma.constants.Null.BYTE;
|
||||||
|
+
|
||||||
|
+ String salt = this.get("rcon.hash.salt", "");
|
||||||
|
+ if (!salt.isBlank()) {
|
||||||
|
+ try {
|
||||||
|
+ return java.util.HexFormat.of().parseHex(salt);
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ LOGGER.error("Invalid RCON salt detected! RCON will be disabled");
|
||||||
|
+ return org.plazmamc.plazma.constants.Null.BYTE;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ byte[] newSalt = new byte[16];
|
||||||
|
+ (new java.security.SecureRandom()).nextBytes(newSalt);
|
||||||
|
+ salt = java.util.HexFormat.of().formatHex(newSalt);
|
||||||
|
+ this.set("rcon.hash.salt", salt);
|
||||||
|
+ return newSalt;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private String rconPassword() {
|
||||||
|
+ String hashed = this.get("rcon.hash.password", "");
|
||||||
|
+ if (!hashed.isBlank()) {
|
||||||
|
+ try {
|
||||||
|
+ java.util.HexFormat.of().parseHex(hashed);
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ LOGGER.error("Invalid hashed RCON password detected! RCON will be disabled");
|
||||||
|
+ return "";
|
||||||
|
+ }
|
||||||
|
+ return hashed;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ String decoded = this.get("rcon.password", "");
|
||||||
|
+ if (decoded.isBlank() || HASH_INSTANCE == null || this.rconSalt.length == 0) return decoded;
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ final java.security.spec.KeySpec spec = new javax.crypto.spec.PBEKeySpec(decoded.toCharArray(), this.rconSalt, this.rconHashIterationCount, 256);
|
||||||
|
+ byte[] hashedByte = HASH_INSTANCE.generateSecret(spec).getEncoded();
|
||||||
|
+ hashed = java.util.HexFormat.of().formatHex(hashedByte);
|
||||||
|
+ this.set("rcon.hash.password", hashed);
|
||||||
|
+ this.remove("rcon.password");
|
||||||
|
+ return hashed;
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ LOGGER.error("Failed to encode rcon password", e);
|
||||||
|
+ return "";
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public Boolean shouldStartRCON() {
|
||||||
|
+ return this.enableRcon && !this.rconPassword.isBlank();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public Boolean matchRconPassword(String value) {
|
||||||
|
+ if (this.rconSalt.length == 0 || HASH_INSTANCE == null) return this.rconPassword.equals(value);
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ final java.security.spec.KeySpec spec = new javax.crypto.spec.PBEKeySpec(value.toCharArray(), this.rconSalt, this.rconHashIterationCount, 256);
|
||||||
|
+ byte[] hashedByte = HASH_INSTANCE.generateSecret(spec).getEncoded();
|
||||||
|
+ String hashed = java.util.HexFormat.of().formatHex(hashedByte);
|
||||||
|
+ return this.rconPassword.equals(hashed);
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ LOGGER.error("Failed to validate rcon password", e);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
+ // Plazma end - hashed rcon password
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
public static DedicatedServerProperties fromFile(Path path, OptionSet optionset) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/Settings.java b/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||||
|
index d7bd235ef2815890e038091dd625177049d253a5..afced52731868d5726b85a03011111adeffeb074 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||||
|
@@ -243,6 +243,11 @@ public abstract class Settings<T extends Settings<T>> {
|
||||||
|
return v1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Plazma start - Settings helper
|
||||||
|
+ protected <V> void set(String key, V value) { this.properties.put(key, value); }
|
||||||
|
+ protected void remove(String key) { this.properties.remove(key); }
|
||||||
|
+ // Plazma end - Settings helper
|
||||||
|
+
|
||||||
|
protected <V> Settings<T>.MutableValue<V> getMutable(String key, Function<String, V> parser, Function<V, String> stringifier, V fallback) {
|
||||||
|
String s1 = this.getStringRaw(key);
|
||||||
|
V v1 = MoreObjects.firstNonNull(s1 != null ? parser.apply(s1) : null, fallback);
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/rcon/thread/RconClient.java b/src/main/java/net/minecraft/server/rcon/thread/RconClient.java
|
||||||
|
index 1c3775c6d29a85803c87948c64ec81cbeb87aef4..4f6f46398ac0814a95d8253cc5f575b8f09f7209 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/rcon/thread/RconClient.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/rcon/thread/RconClient.java
|
||||||
|
@@ -26,13 +26,12 @@ public class RconClient extends GenericThread {
|
||||||
|
private boolean authed;
|
||||||
|
private final Socket client;
|
||||||
|
private final byte[] buf = new byte[1460];
|
||||||
|
- private final String rconPassword;
|
||||||
|
// CraftBukkit start
|
||||||
|
private final DedicatedServer serverInterface;
|
||||||
|
private final RconConsoleSource rconConsoleSource;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
- RconClient(ServerInterface server, String password, Socket socket) {
|
||||||
|
+ RconClient(ServerInterface server, Socket socket) {// Plazma - hashed rcon password
|
||||||
|
super("RCON Client " + String.valueOf(socket.getInetAddress()));
|
||||||
|
this.serverInterface = (DedicatedServer) server; // CraftBukkit
|
||||||
|
this.client = socket;
|
||||||
|
@@ -43,7 +42,6 @@ public class RconClient extends GenericThread {
|
||||||
|
this.running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
- this.rconPassword = password;
|
||||||
|
this.rconConsoleSource = new net.minecraft.server.rcon.RconConsoleSource(this.serverInterface, socket.getRemoteSocketAddress()); // CraftBukkit
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -93,7 +91,7 @@ public class RconClient extends GenericThread {
|
||||||
|
String s1 = PktUtils.stringFromByteArray(this.buf, j, i);
|
||||||
|
int j1 = j + s1.length();
|
||||||
|
|
||||||
|
- if (!s1.isEmpty() && s1.equals(this.rconPassword)) {
|
||||||
|
+ if (!s1.isEmpty() && serverInterface.getProperties().matchRconPassword(s1)) {
|
||||||
|
this.authed = true;
|
||||||
|
this.send(l, 2, "");
|
||||||
|
continue;
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
|
||||||
|
index c12d7db2b048a327c0e8f398848cd3a9bce0ebce..150cecc44a7f49740fa400e02de09671ff8b392a 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
|
||||||
|
@@ -16,15 +16,13 @@ import org.slf4j.Logger;
|
||||||
|
public class RconThread extends GenericThread {
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
private final ServerSocket socket;
|
||||||
|
- private final String rconPassword;
|
||||||
|
private final List<RconClient> clients = Lists.newArrayList();
|
||||||
|
private final ServerInterface serverInterface;
|
||||||
|
|
||||||
|
- private RconThread(ServerInterface server, ServerSocket listener, String password) {
|
||||||
|
+ private RconThread(ServerInterface server, ServerSocket listener) {// Plazma - hashed rcon password
|
||||||
|
super("RCON Listener");
|
||||||
|
this.serverInterface = server;
|
||||||
|
this.socket = listener;
|
||||||
|
- this.rconPassword = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearClients() {
|
||||||
|
@@ -37,7 +35,7 @@ public class RconThread extends GenericThread {
|
||||||
|
while (this.running) {
|
||||||
|
try {
|
||||||
|
Socket socket = this.socket.accept();
|
||||||
|
- RconClient rconClient = new RconClient(this.serverInterface, this.rconPassword, socket);
|
||||||
|
+ RconClient rconClient = new RconClient(this.serverInterface, socket); // Plazma - hashed rcon password
|
||||||
|
rconClient.start();
|
||||||
|
this.clients.add(rconClient);
|
||||||
|
this.clearClients();
|
||||||
|
@@ -64,15 +62,14 @@ public class RconThread extends GenericThread {
|
||||||
|
|
||||||
|
int i = dedicatedServerProperties.rconPort;
|
||||||
|
if (0 < i && 65535 >= i) {
|
||||||
|
- String string2 = dedicatedServerProperties.rconPassword;
|
||||||
|
- if (string2.isEmpty()) {
|
||||||
|
+ if (!dedicatedServerProperties.shouldStartRCON()) { // Plazma - hashed rcon password
|
||||||
|
LOGGER.warn("No rcon password set in server.properties, rcon disabled!");
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
ServerSocket serverSocket = new ServerSocket(i, 0, InetAddress.getByName(string));
|
||||||
|
serverSocket.setSoTimeout(500);
|
||||||
|
- RconThread rconThread = new RconThread(server, serverSocket, string2);
|
||||||
|
+ RconThread rconThread = new RconThread(server, serverSocket); // Plazma - hashed rcon password
|
||||||
|
if (!rconThread.start()) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
333
patches/server/features/0057-Ticking-Controller.patch
Normal file
333
patches/server/features/0057-Ticking-Controller.patch
Normal file
@@ -0,0 +1,333 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Sat, 14 Dec 2024 00:39:05 +0900
|
||||||
|
Subject: [PATCH] Ticking Controller
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
index 8964ccc27ea7db306140fd6b04c9f5cb33158aa0..bd8048bfe2a93c3a4b4bb84e7d992a8bb0c65778 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
@@ -1654,6 +1654,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tickServer(BooleanSupplier shouldKeepTicking) {
|
||||||
|
+ org.plazmamc.plazma.util.TickingController.tick(); // Plazma - TickControl System
|
||||||
|
org.spigotmc.WatchdogThread.tick(); // Spigot
|
||||||
|
long i = Util.getNanos();
|
||||||
|
int j = this.pauseWhileEmptySeconds() * 20;
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/ServerWatchdog.java b/src/main/java/net/minecraft/server/dedicated/ServerWatchdog.java
|
||||||
|
index 660a142036c4e608d3d6fed6ec700a3488400bec..d092bef5e6626f000a44a0f424f247a1a69d34af 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/ServerWatchdog.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/ServerWatchdog.java
|
||||||
|
@@ -34,6 +34,7 @@ public class ServerWatchdog implements Runnable {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (this.server.isRunning()) {
|
||||||
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().tickControl.enabled) return; // Plazma - TickControl System
|
||||||
|
long l = this.server.getNextTickTime();
|
||||||
|
long m = Util.getNanos();
|
||||||
|
long n = m - l;
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
index a84faa2e82a8d33b7bfe71f174f2913b585d99e8..0d8800d05bd6a14b3d5702d6a51f8cb0c7ae2186 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
@@ -630,7 +630,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||||
|
// this.lastSpawnState = spawnercreature_d; // Pufferfish - this is managed asynchronously
|
||||||
|
//profiler.popPush("spawnAndTick"); // Plazma - Completely remove Mojang profiler
|
||||||
|
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
|
||||||
|
- int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
||||||
|
+ int k = org.plazmamc.plazma.util.TickingController.calc(this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING), it -> it.accelerate.randomTick, false); // Plazma - TickControl system
|
||||||
|
List list1;
|
||||||
|
|
||||||
|
if (flag && (this.spawnEnemies || this.spawnFriendlies)) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
index 9a54883281352cc4fa08143f5126d61dbd89761d..982b172b188fb890fa7719662e67a007ab172668 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -909,7 +909,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
|
this.setDayTime(this.preciseTime);
|
||||||
|
} else
|
||||||
|
// Purpur end - Configurable daylight cycle
|
||||||
|
- this.setDayTime(this.levelData.getDayTime() + 1L);
|
||||||
|
+ // Plazma start - TickControl System
|
||||||
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().tickControl.accelerate.dayTime)
|
||||||
|
+ this.setDayTime(this.levelData.getDayTime() + org.plazmamc.plazma.util.TickingController.missedTicks() + 1L);
|
||||||
|
+ else
|
||||||
|
+ this.setDayTime(this.levelData.getDayTime() + 1L);
|
||||||
|
+ // Plazma end - TickControl System
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
index d6d43ad1677d035c26619b73e5a2dd6e72ab278b..ee6ad451ba8755cf296e9c0a01404a5ed025e749 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -562,6 +562,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tickEffects();
|
||||||
|
+ if (plazma.Config.get().tickControl.delay.potionEffect) for (int i = 0; i < org.plazmamc.plazma.util.TickingController.missedTicks(); i++) this.tickEffects(); // Plazma - TickControl System
|
||||||
|
this.animStepO = this.animStep;
|
||||||
|
this.yBodyRotO = this.yBodyRot;
|
||||||
|
this.yHeadRotO = this.yHeadRot;
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/PortalProcessor.java b/src/main/java/net/minecraft/world/entity/PortalProcessor.java
|
||||||
|
index b4a8249964786d484aa0767d0e73d71d2156f0e8..49505d04c737c41e4229d80a7b96d4ed0b68d083 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/PortalProcessor.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/PortalProcessor.java
|
||||||
|
@@ -24,7 +24,7 @@ public class PortalProcessor {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this.insidePortalThisTick = false;
|
||||||
|
- return canUsePortals && this.portalTime++ >= this.portal.getPortalTransitionTime(world, entity);
|
||||||
|
+ return canUsePortals && this.increaseTick() >= this.portal.getPortalTransitionTime(world, entity); // Plazma - TickControl System
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,14 @@ public class PortalProcessor {
|
||||||
|
return this.portal.getPortalDestination(world, entity, this.entryPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Plazma start - TickControl System
|
||||||
|
+ private int increaseTick() {
|
||||||
|
+ if (!plazma.Config.get().tickControl.delay.portalUse)
|
||||||
|
+ this.portalTime += org.plazmamc.plazma.util.TickingController.missedTicks();
|
||||||
|
+ return this.portalTime++;
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - TickControl System
|
||||||
|
+
|
||||||
|
public Portal.Transition getPortalLocalTransition() {
|
||||||
|
return this.portal.getLocalTransition();
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
|
index 4aaaadce69e62fa371d5b441e5e69c1384e5d63e..97c63c335287e01b20687eeea4a5815520363e13 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
|
@@ -158,6 +158,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||||
|
if (this.getItem().isEmpty()) {
|
||||||
|
this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||||
|
} else {
|
||||||
|
+ if (this.pickupDelay > 0 && plazma.Config.get().tickControl.delay.itemPickup) this.pickupDelay = Math.max(this.pickupDelay - org.plazmamc.plazma.util.TickingController.missedTicks(), 0); // Plazma - TickControl System
|
||||||
|
super.tick();
|
||||||
|
// Paper start - remove anti tick skipping measures / wall time - revert to vanilla
|
||||||
|
if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||||
|
index 5a9e85c44fbb716dc1e8616645732cb8db947ee9..4ea1a327c80f915aa45ccf3a5955ed6ff42692c1 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||||
|
@@ -305,6 +305,11 @@ public abstract class Player extends LivingEntity {
|
||||||
|
if (this.sleepCounter > 100) {
|
||||||
|
this.sleepCounter = 100;
|
||||||
|
}
|
||||||
|
+ // Plazma start - TickControl System
|
||||||
|
+ else if (this.sleepCounter < 100 && plazma.Config.get().tickControl.delay.sleep && org.plazmamc.plazma.util.TickingController.missedTicks() > 0) {
|
||||||
|
+ this.sleepCounter += org.plazmamc.plazma.util.TickingController.missedTicks();
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - TickControl System
|
||||||
|
|
||||||
|
if (/*!this.level().isClientSide &&*/ this.level().isDay()) { // Plazma - Remove persist 'isClientSide' flag
|
||||||
|
this.stopSleepInBed(false, true);
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java
|
||||||
|
index 29afbe0aa72f12d8fa6c03af55d17abef89c8dd4..78742ef91ed332d229d007af9224555a79cd6be9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/Item.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/Item.java
|
||||||
|
@@ -260,7 +260,7 @@ public class Item implements FeatureElement, ItemLike {
|
||||||
|
|
||||||
|
public int getUseDuration(ItemStack stack, LivingEntity user) {
|
||||||
|
Consumable consumable = stack.get(DataComponents.CONSUMABLE);
|
||||||
|
- return consumable != null ? consumable.consumeTicks() : 0;
|
||||||
|
+ return consumable != null ? org.plazmamc.plazma.util.TickingController.calc(consumable.consumeTicks(), it -> it.delay.itemUse, true) : 0; // Plazma - TickControl System
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean releaseUsing(ItemStack stack, Level world, LivingEntity user, int remainingUseTicks) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||||
|
index c8ae6e4cd74549f753ec04def5d882de1ab72308..b01b80ff0318f95a737ce3f93a5c69426019cc9c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||||
|
@@ -336,13 +336,14 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||||
|
protected float getDestroyProgress(BlockState state, Player player, BlockGetter world, BlockPos pos) {
|
||||||
|
float f = state.getDestroySpeed(world, pos);
|
||||||
|
|
||||||
|
- if (f == -1.0F) {
|
||||||
|
- return 0.0F;
|
||||||
|
- } else {
|
||||||
|
- int i = player.hasCorrectToolForDrops(state) ? 30 : 100;
|
||||||
|
-
|
||||||
|
- return player.getDestroySpeed(state) / f / (float) i;
|
||||||
|
- }
|
||||||
|
+ // Plazma start - TickControl system
|
||||||
|
+ if (f == -1.0F) return 0.0F;
|
||||||
|
+ return org.plazmamc.plazma.util.TickingController.calc(
|
||||||
|
+ player.getDestroySpeed(state) / f / (player.hasCorrectToolForDrops(state) ? 30 : 100),
|
||||||
|
+ it -> it.delay.blockBreak,
|
||||||
|
+ false
|
||||||
|
+ );
|
||||||
|
+ // Plazma end - TickControl system
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void spawnAfterBreak(BlockState state, ServerLevel world, BlockPos pos, ItemStack tool, boolean dropExperience) {}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||||
|
index a1756429e8fc09cfd78109c4d5113857304b317d..158da3ebd4b09d8c682960ff658a2e861cbee6dc 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||||
|
@@ -1081,8 +1081,18 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||||
|
this.chunkCoordinateKey = chunkCoordinateKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Plazma start - TickControl System
|
||||||
|
+ private void tickTicker(BlockState state) {
|
||||||
|
+ this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), state, this.blockEntity);
|
||||||
|
+
|
||||||
|
+ if (!org.plazmamc.plazma.util.TickingController.shouldTickAgain(state.getBlock())) return;
|
||||||
|
+ for (int i = 0; i < org.plazmamc.plazma.util.TickingController.missedTicks(); i++)
|
||||||
|
+ this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), state, this.blockEntity);
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - TickControl System
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
- public void tick() {
|
||||||
|
+ public final void tick() { // Plazma - TickControl System (make final)
|
||||||
|
if (this.blockEntity.isRemoved() || !this.blockEntity.hasLevel()) return;
|
||||||
|
|
||||||
|
BlockPos pos = this.blockEntity.getBlockPos();
|
||||||
|
@@ -1092,7 +1102,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||||
|
BlockState state = LevelChunk.this.getBlockState(pos);
|
||||||
|
|
||||||
|
if (this.blockEntity.getType().isValid(state)) {
|
||||||
|
- this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), state, this.blockEntity);
|
||||||
|
+ this.tickTicker(state); // Plazma - TickControl System
|
||||||
|
this.loggedInvalidBlockState = false;
|
||||||
|
// Paper start - Remove the Block Entity if it's invalid
|
||||||
|
} else {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
|
||||||
|
index 6e643c1a7f7e71cfd20603facaf224985ee81716..cbbbcf8a915a4146eb63e29ba5dd91354ac7228b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
|
||||||
|
@@ -181,7 +181,7 @@ public abstract class LavaFluid extends FlowingFluid {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTickDelay(LevelReader world) {
|
||||||
|
- return world.dimensionType().ultraWarm() ? world.getWorldBorder().world.purpurConfig.lavaSpeedNether : world.getWorldBorder().world.purpurConfig.lavaSpeedNotNether; // Purpur
|
||||||
|
+ return org.plazmamc.plazma.util.TickingController.calc(world.dimensionType().ultraWarm() ? world.getWorldBorder().world.purpurConfig.lavaSpeedNether : world.getWorldBorder().world.purpurConfig.lavaSpeedNotNether, it -> it.delay.lavaFluid, true); // Purpur // Plazma - TickControl system
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||||
|
index 028aea6640356ba80f5d682e3cc03b7f82f5b9c7..d788849dc5a568d455cd83ca5b6e1b4ba1a9161f 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||||
|
@@ -123,7 +123,7 @@ public abstract class WaterFluid extends FlowingFluid {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTickDelay(LevelReader world) {
|
||||||
|
- return world.getWorldBorder().world.plazmaConfig().block.waterFlowingTick; // Plazma - Configurable water flowing speed
|
||||||
|
+ return org.plazmamc.plazma.util.TickingController.calc(world.getWorldBorder().world.plazmaConfig().block.waterFlowingTick, it -> it.delay.waterFluid, true); // Plazma - Configurable water flowing speed // Plazma - TickControl System
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
index 768cb135081c233a820566015ed58351e417c45c..898f9e6ec6f306a15639ee0d03bcfe7bf55e2c6c 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
@@ -195,4 +195,39 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public TickControl tickControl;
|
||||||
|
+ public class TickControl extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public boolean enabled = false;
|
||||||
|
+
|
||||||
|
+ public Delay delay;
|
||||||
|
+ public class Delay extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public boolean sleep = true;
|
||||||
|
+ public boolean itemUse = true;
|
||||||
|
+ public boolean portalUse = true;
|
||||||
|
+ public boolean lavaFluid = true;
|
||||||
|
+ public boolean waterFluid = true;
|
||||||
|
+ public boolean blockBreak = true;
|
||||||
|
+ public boolean itemPickup = true;
|
||||||
|
+ public boolean potionEffect = true;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public Accelerate accelerate;
|
||||||
|
+ public class Accelerate extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public boolean dayTime = true;
|
||||||
|
+ public boolean randomTick = true;
|
||||||
|
+ public boolean blockEntity = true;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @PostProcess
|
||||||
|
+ void post() {
|
||||||
|
+ org.plazmamc.plazma.util.TickingController.post(this);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/util/TickingController.java b/src/main/java/org/plazmamc/plazma/util/TickingController.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..0e71a47a639a1a3dd0918c5a403ed827aca67966
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/util/TickingController.java
|
||||||
|
@@ -0,0 +1,56 @@
|
||||||
|
+package org.plazmamc.plazma.util;
|
||||||
|
+
|
||||||
|
+import net.minecraft.world.level.block.Block;
|
||||||
|
+import org.jspecify.annotations.NonNull;
|
||||||
|
+import org.jspecify.annotations.Nullable;
|
||||||
|
+import org.plazmamc.plazma.configurations.GlobalConfiguration;
|
||||||
|
+import java.util.function.Function;
|
||||||
|
+
|
||||||
|
+import static net.minecraft.server.MinecraftServer.getServer;
|
||||||
|
+
|
||||||
|
+public final class TickingController {
|
||||||
|
+
|
||||||
|
+ private static @Nullable TickingController INSTANCE;
|
||||||
|
+ private final GlobalConfiguration.TickControl configuration;
|
||||||
|
+ private int missedTicks = 0;
|
||||||
|
+
|
||||||
|
+ private TickingController(GlobalConfiguration.TickControl configuration) {
|
||||||
|
+ this.configuration = configuration;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void tick() {
|
||||||
|
+ if (INSTANCE == null) return;
|
||||||
|
+ INSTANCE.missedTicks -= INSTANCE.missedTicks;
|
||||||
|
+ INSTANCE.missedTicks += (int) (getServer().tickTimes5s.getAverage() / 50 - 1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void post(GlobalConfiguration.TickControl configuration) {
|
||||||
|
+ if (!configuration.enabled) {
|
||||||
|
+ INSTANCE = null;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ INSTANCE = new TickingController(configuration);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static float calc(float original, @NonNull Function<GlobalConfiguration.TickControl, Boolean> isAffected, boolean swap) {
|
||||||
|
+ if (INSTANCE == null || !isAffected.apply(INSTANCE.configuration) || original == 0) return original;
|
||||||
|
+ if (swap) return (float) Math.max(original * getServer().tps5s.getAverage() / 20, 1);
|
||||||
|
+ return (float) (original * 20 / getServer().tps5s.getAverage());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int calc(int original, @NonNull Function<GlobalConfiguration.TickControl, Boolean> isAccelerated, boolean swap) {
|
||||||
|
+ return (int) Math.ceil(calc((float) original, isAccelerated, swap));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int missedTicks() {
|
||||||
|
+ if (INSTANCE == null) return 0;
|
||||||
|
+ return INSTANCE.missedTicks;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static boolean shouldTickAgain(Block block) {
|
||||||
|
+ // TODO: Configurable block masking
|
||||||
|
+ return INSTANCE != null && !INSTANCE.configuration.accelerate.blockEntity;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
225
patches/server/features/0064-Bundle-as-quivers.patch
Normal file
225
patches/server/features/0064-Bundle-as-quivers.patch
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Wed, 22 Jan 2025 11:50:19 +0900
|
||||||
|
Subject: [PATCH] Bundle as quivers
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
index ee6ad451ba8755cf296e9c0a01404a5ed025e749..53c62f51bcdaecba265eb2e0f5e69e890b1b0b03 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -4774,7 +4774,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
return !this.isSleeping() && super.isInWall();
|
||||||
|
}
|
||||||
|
|
||||||
|
- public ItemStack getProjectile(ItemStack stack) {
|
||||||
|
+ // Plazma start - Bundle as quivers!
|
||||||
|
+ public final ItemStack getProjectile(final ItemStack stack) {
|
||||||
|
+ return this.getProjectile(stack, false, false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ItemStack getProjectile(final ItemStack stack, final boolean bundle, final boolean shrink) {
|
||||||
|
+ // Plazma end - Bundle as quivers!
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Monster.java b/src/main/java/net/minecraft/world/entity/monster/Monster.java
|
||||||
|
index c2061f575c731ecc6071384b007517c08e0cf983..a9f7a1ef69fa6fb8ce45237dd812a4827eb5940d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/monster/Monster.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Monster.java
|
||||||
|
@@ -143,7 +143,7 @@ public abstract class Monster extends PathfinderMob implements Enemy {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public ItemStack getProjectile(ItemStack stack) {
|
||||||
|
+ public final ItemStack getProjectile(final ItemStack stack, final boolean bundle, final boolean shrink) { // Plazma - Bundle as quivers!
|
||||||
|
if (stack.getItem() instanceof ProjectileWeaponItem) {
|
||||||
|
Predicate<ItemStack> predicate = ((ProjectileWeaponItem)stack.getItem()).getSupportedHeldProjectiles();
|
||||||
|
ItemStack itemStack = ProjectileWeaponItem.getHeldProjectile(this, predicate);
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||||
|
index 4ea1a327c80f915aa45ccf3a5955ed6ff42692c1..121c2a78b0ae30785dcb3587cfd228d049e10993 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||||
|
@@ -2321,30 +2321,49 @@ public abstract class Player extends LivingEntity {
|
||||||
|
// Paper end - PlayerReadyArrowEvent
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public ItemStack getProjectile(ItemStack stack) {
|
||||||
|
- if (!(stack.getItem() instanceof ProjectileWeaponItem)) {
|
||||||
|
- return ItemStack.EMPTY;
|
||||||
|
- } else {
|
||||||
|
- Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper - PlayerReadyArrowEvent
|
||||||
|
- ItemStack itemstack1 = ProjectileWeaponItem.getHeldProjectile(this, predicate);
|
||||||
|
+ // Plazma start - Bundle as quivers!
|
||||||
|
+ public final ItemStack getProjectile(final ItemStack stack, final boolean bundle, final boolean shrink) {
|
||||||
|
+ if (!(stack.getItem() instanceof ProjectileWeaponItem weapon)) return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
- if (!itemstack1.isEmpty()) {
|
||||||
|
- return itemstack1;
|
||||||
|
- } else {
|
||||||
|
- predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper - PlayerReadyArrowEvent
|
||||||
|
+ Predicate<ItemStack> predicate = weapon.getSupportedHeldProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper - PlayerReadyArrowEvent
|
||||||
|
+ final ItemStack held = ProjectileWeaponItem.getHeldProjectile(this, predicate);
|
||||||
|
+ if (!held.isEmpty()) return held;
|
||||||
|
+
|
||||||
|
+ predicate = weapon.getAllSupportedProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper - PlayerReadyArrowEvent
|
||||||
|
+ for (int i = 0; i < this.inventory.getContainerSize(); ++i) {
|
||||||
|
+ ItemStack item = this.inventory.getItem(i);
|
||||||
|
|
||||||
|
- for (int i = 0; i < this.inventory.getContainerSize(); ++i) {
|
||||||
|
- ItemStack itemstack2 = this.inventory.getItem(i);
|
||||||
|
+ if (bundle && item.getItem() instanceof net.minecraft.world.item.BundleItem) {
|
||||||
|
+ final net.minecraft.world.item.component.BundleContents contents = item.get(net.minecraft.core.component.DataComponents.BUNDLE_CONTENTS);
|
||||||
|
+ if (contents == null || contents.isEmpty()) continue;
|
||||||
|
|
||||||
|
- if (predicate.test(itemstack2)) {
|
||||||
|
- return itemstack2;
|
||||||
|
- }
|
||||||
|
+ final Optional<ItemStack> optional = contents.itemCopyStream().filter(predicate).findFirst();
|
||||||
|
+ if (optional.isEmpty()) continue;
|
||||||
|
+
|
||||||
|
+ final ItemStack first = optional.get();
|
||||||
|
+ if (shrink) {
|
||||||
|
+ final net.minecraft.world.item.component.BundleContents.Mutable mutable = new net.minecraft.world.item.component.BundleContents.Mutable(contents);
|
||||||
|
+ final ItemStack next = mutable.removeOne(first.copyAndClear());
|
||||||
|
+ if (next == null) continue;
|
||||||
|
+
|
||||||
|
+ next.shrink(1);
|
||||||
|
+ if (next.getCount() != 0) mutable.tryInsert(next);
|
||||||
|
+
|
||||||
|
+ item.set(net.minecraft.core.component.DataComponents.BUNDLE_CONTENTS, mutable.toImmutable());
|
||||||
|
}
|
||||||
|
|
||||||
|
- return this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY;
|
||||||
|
+ first.setCount(1);
|
||||||
|
+ return first;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (predicate.test(item)) {
|
||||||
|
+ return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ return this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
+ // Plazma end - Bundle as quivers!
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec3 getRopeHoldPosition(float delta) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java
|
||||||
|
index 58fa528e4b2589d362eb976afd6221cd94f2623c..6a2381e37709b05a9c5e49c34d549a6da1b8f388 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/BowItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/BowItem.java
|
||||||
|
@@ -27,7 +27,7 @@ public class BowItem extends ProjectileWeaponItem {
|
||||||
|
if (!(user instanceof Player player)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
- ItemStack itemStack = player.getProjectile(stack);
|
||||||
|
+ ItemStack itemStack = player.getProjectile(stack, world.plazmaConfig().item.bundleAsQuivers.enableForBow, net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, stack) == 0); // Plazma - Bundle as quivers!
|
||||||
|
// Purpur start
|
||||||
|
if (world.purpurConfig.infinityWorksWithoutArrows && itemStack.isEmpty() && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, stack) > 0) {
|
||||||
|
itemStack = new ItemStack(Items.ARROW);
|
||||||
|
@@ -93,7 +93,7 @@ public class BowItem extends ProjectileWeaponItem {
|
||||||
|
@Override
|
||||||
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
|
ItemStack itemStack = user.getItemInHand(hand);
|
||||||
|
- boolean bl = !user.getProjectile(itemStack).isEmpty();
|
||||||
|
+ boolean bl = !user.getProjectile(itemStack, world.plazmaConfig().item.bundleAsQuivers.enableForBow, false).isEmpty();
|
||||||
|
if (!user.hasInfiniteMaterials() && !bl && !(world.purpurConfig.infinityWorksWithoutArrows && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemStack) > 0)) { // Purpur
|
||||||
|
return InteractionResult.FAIL;
|
||||||
|
} else {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/CrossbowItem.java b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
||||||
|
index f8946704838d96ad522182d2b9f41ac8bfe92ac4..c46b5e6fb007280b1ff264414c9acaf8a5f49101 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
||||||
|
@@ -72,7 +72,7 @@ public class CrossbowItem extends ProjectileWeaponItem {
|
||||||
|
if (chargedProjectiles != null && !chargedProjectiles.isEmpty()) {
|
||||||
|
this.performShooting(world, user, hand, itemStack, getShootingPower(chargedProjectiles), (float) world.purpurConfig.crossbowProjectileOffset, null); // Purpur
|
||||||
|
return InteractionResult.CONSUME;
|
||||||
|
- } else if (!user.getProjectile(itemStack).isEmpty()) {
|
||||||
|
+ } else if (!user.getProjectile(itemStack, world.plazmaConfig().item.bundleAsQuivers.enableForCrossbow, false).isEmpty() || net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemStack) > 0 && world.plazmaConfig().item.allowCrossbowInfinity) { // Plazma - Bundle as quivers!
|
||||||
|
this.startSoundPlayed = false;
|
||||||
|
this.midLoadSoundPlayed = false;
|
||||||
|
user.startUsingItem(hand);
|
||||||
|
@@ -124,7 +124,11 @@ public class CrossbowItem extends ProjectileWeaponItem {
|
||||||
|
return CrossbowItem.tryLoadProjectiles(shooter, crossbow, true);
|
||||||
|
}
|
||||||
|
private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack crossbow, boolean consume) {
|
||||||
|
- List<ItemStack> list = draw(crossbow, shooter.getProjectile(crossbow), shooter, consume);
|
||||||
|
+ // Plazma start - Bundle as quivers!
|
||||||
|
+ boolean infinity = net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, crossbow) > 0 && shooter.level().plazmaConfig().item.allowCrossbowInfinity;
|
||||||
|
+ List<ItemStack> list = draw(crossbow, shooter.getProjectile(crossbow, shooter.level().plazmaConfig().item.bundleAsQuivers.enableForBow, !infinity), shooter, consume);
|
||||||
|
+ if (list.isEmpty() && infinity) list = List.of(new ItemStack(Items.ARROW));
|
||||||
|
+ // Plazma end - Bundle as quivers!
|
||||||
|
// Paper end - Add EntityLoadCrossbowEvent
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
crossbow.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.of(list));
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/component/BundleContents.java b/src/main/java/net/minecraft/world/item/component/BundleContents.java
|
||||||
|
index d4e7e92875162b67226a20c5add8973e09fd882c..6e57ed3b395b0155bdf13129c11ee8ddf4a68199 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/component/BundleContents.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/component/BundleContents.java
|
||||||
|
@@ -157,7 +157,13 @@ public final class BundleContents implements TooltipComponent {
|
||||||
|
}
|
||||||
|
|
||||||
|
private int findStackIndex(ItemStack stack) {
|
||||||
|
- if (!stack.isStackable()) {
|
||||||
|
+ // Plazma start - Bundle as quivers!
|
||||||
|
+ return this.findStackIndex(stack, false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private int findStackIndex(final ItemStack stack, final boolean skipStackableCheck) {
|
||||||
|
+ if (!skipStackableCheck && !stack.isStackable()) {
|
||||||
|
+ // Plazma end - Bundle as quivers!
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < this.items.size(); i++) {
|
||||||
|
@@ -211,11 +217,20 @@ public final class BundleContents implements TooltipComponent {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public ItemStack removeOne() {
|
||||||
|
+ // Plazma start - Bundle as quivers!
|
||||||
|
+ return this.removeOne(null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ public ItemStack removeOne(final @Nullable ItemStack stack) {
|
||||||
|
+ // Plazma end - Bundle as quivers!
|
||||||
|
if (this.items.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
- int i = this.selectedItem != -1 && this.selectedItem < this.items.size() ? this.selectedItem : 0;
|
||||||
|
- ItemStack itemStack = this.items.remove(i).copy();
|
||||||
|
+ // Plazma start - Bundle as quivers!
|
||||||
|
+ int i = stack != null ? this.findStackIndex(stack, true) : this.selectedItem != -1 && this.selectedItem < this.items.size() ? this.selectedItem : 0;
|
||||||
|
+ ItemStack itemStack = this.items.remove(i != -1 ? i : 0).copy();
|
||||||
|
+ // Plazma end - Bundle as quivers!
|
||||||
|
this.weight = this.weight.subtract(BundleContents.getWeight(itemStack).multiplyBy(Fraction.getFraction(itemStack.getCount(), 1)));
|
||||||
|
this.toggleSelectedItem(-1);
|
||||||
|
return itemStack;
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
index e88b18ff76bf21d9fa340a1d58abedefbf30ec91..8daf361f82af8d41661d8c5afe717c8a90803dfe 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
@@ -104,6 +104,7 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||||
|
public class Item extends ConfigurationPart {
|
||||||
|
|
||||||
|
public boolean skipMapUpdateIfCraftRenderIsNull = true;
|
||||||
|
+ public boolean allowCrossbowInfinity = false;
|
||||||
|
|
||||||
|
public ShootableFireCharge shootableFireCharge;
|
||||||
|
public class ShootableFireCharge extends ConfigurationPart {
|
||||||
|
@@ -125,6 +126,14 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public BundleAsQuivers bundleAsQuivers;
|
||||||
|
+ public class BundleAsQuivers extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public boolean enableForBow = false;
|
||||||
|
+ public boolean enableForCrossbow = false;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,227 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Sat, 14 Dec 2024 00:29:15 +0900
|
||||||
|
Subject: [PATCH] Implement CarpetFixes
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||||
|
index 0503f936d0d7194f110069adabff984f51af0a3a..0ca88636cca9b8f93cddf8bc58038e626e171df8 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||||
|
@@ -379,19 +379,22 @@ public class Sheep extends Animal implements Shearable {
|
||||||
|
}
|
||||||
|
|
||||||
|
private DyeColor getOffspringColor(ServerLevel world, Sheep firstParent, Sheep secondParent) {
|
||||||
|
- DyeColor enumcolor = firstParent.getColor();
|
||||||
|
- DyeColor enumcolor1 = secondParent.getColor();
|
||||||
|
- CraftingInput craftinginput = Sheep.makeCraftInput(enumcolor, enumcolor1);
|
||||||
|
- Optional<Item> optional = world.recipeAccess().getRecipeFor(RecipeType.CRAFTING, craftinginput, world).map((recipeholder) -> { // CraftBukkit - decompile error
|
||||||
|
- return ((CraftingRecipe) recipeholder.value()).assemble(craftinginput, world.registryAccess());
|
||||||
|
- }).map(ItemStack::getItem);
|
||||||
|
-
|
||||||
|
- Objects.requireNonNull(DyeItem.class);
|
||||||
|
- optional = optional.filter(DyeItem.class::isInstance);
|
||||||
|
- Objects.requireNonNull(DyeItem.class);
|
||||||
|
- return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> {
|
||||||
|
- return world.random.nextBoolean() ? enumcolor : enumcolor1;
|
||||||
|
- });
|
||||||
|
+ // Plazma start - Implement CarpetFixes
|
||||||
|
+ final DyeColor firstColor = firstParent.getColor();
|
||||||
|
+ final DyeColor secondColor = secondParent.getColor();
|
||||||
|
+// PLAZMA - REMOVE THIS
|
||||||
|
+ if (world.plazmaConfig().carpetFixes.preparedSheepChildColor) {
|
||||||
|
+ final DyeColor color = org.plazmamc.plazma.util.CarpetFixes.properDyeMixin(firstColor, secondColor);
|
||||||
|
+ if (color != null) return color;
|
||||||
|
+ return world.random.nextBoolean() ? firstColor : secondColor;
|
||||||
|
+ }
|
||||||
|
+// PLAZMA - REMOVE THIS
|
||||||
|
+ final CraftingInput input = Sheep.makeCraftInput(firstColor, secondColor);
|
||||||
|
+// PLAZMA - REMOVE THIS
|
||||||
|
+ Optional<Item> result = world.recipeAccess().getRecipeFor(RecipeType.CRAFTING, input, world).map((recipeholder) -> recipeholder.value().assemble(input, world.registryAccess())).map(ItemStack::getItem);
|
||||||
|
+ result = result.filter(DyeItem.class::isInstance);
|
||||||
|
+ return result.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> world.random.nextBoolean() ? firstColor : secondColor);
|
||||||
|
+ // Plazma end - Implement CarpetFixes
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CraftingInput makeCraftInput(DyeColor firstColor, DyeColor secondColor) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||||
|
index 90f8360f547ce709fd13ee34f8e67d8bfa94b498..4e5fb377696c0a98a56f9ea11d0116b28399c8f6 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||||
|
@@ -9,6 +9,8 @@ import net.minecraft.util.Mth;
|
||||||
|
|
||||||
|
public class BiomeManager {
|
||||||
|
public static final int CHUNK_CENTER_QUART = QuartPos.fromBlock(8);
|
||||||
|
+ public static boolean PLAZMA_CARPET_FIXES = false; // Plazma - Implement CarpetFixes
|
||||||
|
+ private static final double MAX_OFFSET = 0.450_000_000_1; // Plazma - Implement CarpetFixes
|
||||||
|
private static final int ZOOM_BITS = 2;
|
||||||
|
private static final int ZOOM = 4;
|
||||||
|
private static final int ZOOM_MASK = 3;
|
||||||
|
@@ -29,6 +31,79 @@ public class BiomeManager {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Holder<Biome> getBiome(BlockPos pos) {
|
||||||
|
+ // Plazma start - Implement CarpetFixes
|
||||||
|
+ if (PLAZMA_CARPET_FIXES) {
|
||||||
|
+ final int x2 = pos.getX() - 2;
|
||||||
|
+ final int y2 = pos.getY() - 2;
|
||||||
|
+ final int z2 = pos.getZ() - 2;
|
||||||
|
+
|
||||||
|
+ final int x = x2 >> 2;
|
||||||
|
+ final int y = y2 >> 2;
|
||||||
|
+ final int z = z2 >> 2;
|
||||||
|
+
|
||||||
|
+ final double qX = (x2 & 3) / 4.0D;
|
||||||
|
+ final double qY = (y2 & 3) / 4.0D;
|
||||||
|
+ final double qZ = (z2 & 3) / 4.0D;
|
||||||
|
+
|
||||||
|
+ int minX = 0;
|
||||||
|
+ double minD = Double.POSITIVE_INFINITY;
|
||||||
|
+ for (int bX = 0; bX < 8; ++bX) {
|
||||||
|
+ final boolean x0 = (bX & 4) == 0;
|
||||||
|
+ final boolean y0 = (bX & 2) == 0;
|
||||||
|
+ final boolean z0 = (bX & 1) == 0;
|
||||||
|
+
|
||||||
|
+ final double x1 = x0 ? qX : qX - 1.0D;
|
||||||
|
+ final double y1 = y0 ? qY : qY - 1.0D;
|
||||||
|
+ final double z1 = z0 ? qZ : qZ - 1.0D;
|
||||||
|
+
|
||||||
|
+ double maxQY = 0.0D;
|
||||||
|
+ double maxQZ = 0.0D;
|
||||||
|
+ if (bX != 0) {
|
||||||
|
+ final double maxQX = Mth.square(Math.max(x1 + MAX_OFFSET, Math.abs(x1 - MAX_OFFSET)));
|
||||||
|
+ maxQY = Mth.square(Math.max(y1 + MAX_OFFSET, Math.abs(y1 - MAX_OFFSET)));
|
||||||
|
+ maxQZ = Mth.square(Math.max(z1 + MAX_OFFSET, Math.abs(z1 - MAX_OFFSET)));
|
||||||
|
+
|
||||||
|
+ if (minD < maxQY + maxQZ + maxQX) continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int pX = x0 ? x : x + 1;
|
||||||
|
+ int pY = y0 ? y : y + 1;
|
||||||
|
+ int pZ = z0 ? z : z + 1;
|
||||||
|
+
|
||||||
|
+ long seed = this.biomeZoomSeed;
|
||||||
|
+ seed = LinearCongruentialGenerator.next(seed, pX);
|
||||||
|
+ seed = LinearCongruentialGenerator.next(seed, pY);
|
||||||
|
+ seed = LinearCongruentialGenerator.next(seed, pZ);
|
||||||
|
+ seed = LinearCongruentialGenerator.next(seed, pX);
|
||||||
|
+ seed = LinearCongruentialGenerator.next(seed, pY);
|
||||||
|
+ seed = LinearCongruentialGenerator.next(seed, pZ);
|
||||||
|
+
|
||||||
|
+ double dX = getFiddle(seed);
|
||||||
|
+ double sX = Mth.square(x1 + dX);
|
||||||
|
+ if (bX != 0 && minD < sX + maxQY + maxQZ) continue;
|
||||||
|
+
|
||||||
|
+ seed = LinearCongruentialGenerator.next(seed, this.biomeZoomSeed);
|
||||||
|
+ double dY = getFiddle(seed);
|
||||||
|
+ double sY = Mth.square(y1 + dY);
|
||||||
|
+ if (bX != 0 && minD < sX + sY + maxQZ) continue;
|
||||||
|
+
|
||||||
|
+ seed = LinearCongruentialGenerator.next(seed, this.biomeZoomSeed);
|
||||||
|
+ double dZ = getFiddle(seed);
|
||||||
|
+ double bD = sX + sY + Mth.square(z1 + dZ);
|
||||||
|
+
|
||||||
|
+ if (minD <= bD) continue;
|
||||||
|
+ minX = bX;
|
||||||
|
+ minD = bD;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return this.noiseBiomeSource.getNoiseBiome(
|
||||||
|
+ (minX & 4) == 0 ? x : x + 1,
|
||||||
|
+ (minX & 2) == 0 ? y : y + 1,
|
||||||
|
+ (minX & 1) == 0 ? z : z + 1
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
+ // Plazma end - Implement CarpetFixes
|
||||||
|
+
|
||||||
|
int i = pos.getX() - 2;
|
||||||
|
int j = pos.getY() - 2;
|
||||||
|
int k = pos.getZ() - 2;
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
index 538c572661bd92666f84e6f9ef3e9760f69f50a9..db31d0c066e92fe308e7e64075e832bec66a5c02 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
@@ -188,4 +188,16 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public CarpetFixes carpetFixes;
|
||||||
|
+ public class CarpetFixes extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ boolean optimizeBiomeAccess = OPTIMIZE;
|
||||||
|
+
|
||||||
|
+ @PostProcess
|
||||||
|
+ void post() {
|
||||||
|
+ net.minecraft.world.level.biome.BiomeManager.PLAZMA_CARPET_FIXES = this.optimizeBiomeAccess;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
index 36345efa302413ad4e7d6e611d182572622f76ff..d314be46a02d73e669088d3a37937c8751f7735d 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
@@ -126,4 +126,11 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public CarpetFixes carpetFixes;
|
||||||
|
+ public class CarpetFixes extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public boolean preparedSheepChildColor = OPTIMIZE;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/util/CarpetFixes.java b/src/main/java/org/plazmamc/plazma/util/CarpetFixes.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..a5b0ce75a0ffa65e357cde2d55b7a0f116a2afad
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/util/CarpetFixes.java
|
||||||
|
@@ -0,0 +1,45 @@
|
||||||
|
+package org.plazmamc.plazma.util;
|
||||||
|
+
|
||||||
|
+import net.minecraft.world.item.DyeColor;
|
||||||
|
+
|
||||||
|
+public interface CarpetFixes {
|
||||||
|
+
|
||||||
|
+ static DyeColor properDyeMixin(DyeColor firstColor, DyeColor secondColor) {
|
||||||
|
+ if (firstColor.equals(secondColor)) return firstColor;
|
||||||
|
+
|
||||||
|
+ return switch (firstColor) {
|
||||||
|
+ case WHITE -> switch (secondColor) {
|
||||||
|
+ case BLUE -> DyeColor.LIGHT_BLUE;
|
||||||
|
+ case GRAY -> DyeColor.LIGHT_GRAY;
|
||||||
|
+ case BLACK -> DyeColor.GRAY;
|
||||||
|
+ case GREEN -> DyeColor.LIME;
|
||||||
|
+ case RED -> DyeColor.PINK;
|
||||||
|
+ default -> null;
|
||||||
|
+ };
|
||||||
|
+ case BLUE -> switch (secondColor) {
|
||||||
|
+ case WHITE -> DyeColor.LIGHT_BLUE;
|
||||||
|
+ case GREEN -> DyeColor.CYAN;
|
||||||
|
+ case RED -> DyeColor.PURPLE;
|
||||||
|
+ default -> null;
|
||||||
|
+ };
|
||||||
|
+ case RED -> switch (secondColor) {
|
||||||
|
+ case YELLOW -> DyeColor.ORANGE;
|
||||||
|
+ case WHITE -> DyeColor.PINK;
|
||||||
|
+ case BLUE -> DyeColor.PURPLE;
|
||||||
|
+ default -> null;
|
||||||
|
+ };
|
||||||
|
+ case GREEN -> switch (secondColor) {
|
||||||
|
+ case BLUE -> DyeColor.CYAN;
|
||||||
|
+ case WHITE -> DyeColor.LIME;
|
||||||
|
+ default -> null;
|
||||||
|
+ };
|
||||||
|
+ case YELLOW -> secondColor.equals(DyeColor.RED) ? DyeColor.ORANGE : null;
|
||||||
|
+ case PURPLE -> secondColor.equals(DyeColor.PINK) ? DyeColor.MAGENTA : null;
|
||||||
|
+ case PINK -> secondColor.equals(DyeColor.PURPLE) ? DyeColor.MAGENTA : null;
|
||||||
|
+ case GRAY -> secondColor.equals(DyeColor.WHITE) ? DyeColor.LIGHT_GRAY : null;
|
||||||
|
+ case BLACK -> secondColor.equals(DyeColor.WHITE) ? DyeColor.GRAY : null;
|
||||||
|
+ default -> null;
|
||||||
|
+ };
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Sat, 26 Oct 2024 18:09:08 +0900
|
||||||
|
Subject: [PATCH] Load player data asynchronously
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
|
index 16069b9cbf6c7679c28a2e9a54e77d23cd10e541..bb10892f33ba0d7fc3959debef1045073868f8b8 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
|
@@ -76,7 +76,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||||
|
// CraftBukkit end
|
||||||
|
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
||||||
|
static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
- private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads
|
||||||
|
+ public static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads // Plazma - private -> public
|
||||||
|
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
||||||
|
private final byte[] challenge;
|
||||||
|
final MinecraftServer server;
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||||
|
index aead28160c7a5067340ec80a833eafcab1817d67..c18868796957c0756aca3b5a15fd0d0c8a5221f4 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||||
|
@@ -183,6 +183,16 @@ public abstract class PlayerList {
|
||||||
|
abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor
|
||||||
|
|
||||||
|
public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData) {
|
||||||
|
+ // Plazma start - load player information asynchronously
|
||||||
|
+ if (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().player.loadAsynchronously)
|
||||||
|
+ this.placeNewPlayer(connection, player, clientData, this.load(player));
|
||||||
|
+ else java.util.concurrent.CompletableFuture
|
||||||
|
+ .supplyAsync(() -> this.load(player), net.minecraft.server.network.ServerLoginPacketListenerImpl.authenticatorPool)
|
||||||
|
+ .thenAcceptAsync(nbt -> this.placeNewPlayer(connection, player, clientData, nbt), this.server);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData, Optional<CompoundTag> optional) {
|
||||||
|
+ // Plazma end - load player information asynchronously
|
||||||
|
player.isRealPlayer = true; // Paper
|
||||||
|
player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed
|
||||||
|
GameProfile gameprofile = player.getGameProfile();
|
||||||
|
@@ -191,14 +201,13 @@ public abstract class PlayerList {
|
||||||
|
String s;
|
||||||
|
|
||||||
|
if (usercache != null) {
|
||||||
|
- Optional<GameProfile> optional = usercache.get(gameprofile.getId()); // CraftBukkit - decompile error
|
||||||
|
- s = (String) optional.map(GameProfile::getName).orElse(gameprofile.getName());
|
||||||
|
+ s = usercache.get(gameprofile.getId()).map(GameProfile::getName).orElse(gameprofile.getName()); // CraftBukkit - decompile error // Plazma - varname conflict
|
||||||
|
usercache.add(gameprofile);
|
||||||
|
} else {
|
||||||
|
s = gameprofile.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
- Optional<CompoundTag> optional = this.load(player); // CraftBukkit - decompile error
|
||||||
|
+ // Optional<CompoundTag> optional = this.load(player); // CraftBukkit - decompile error // Plazma - extract
|
||||||
|
ResourceKey<Level> resourcekey = null; // Paper
|
||||||
|
// CraftBukkit start - Better rename detection
|
||||||
|
if (optional.isPresent()) {
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
index 14ba63f5ef6ad5d96972b18e1174a8a94491fa57..c2f3facf65aa2682306c64c3466357461a76f267 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
@@ -44,6 +44,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
public class Player extends ConfigurationPart {
|
||||||
|
|
||||||
|
public boolean checkSpectatorMovedToQuickly = !OPTIMIZE;
|
||||||
|
+ public boolean loadAsynchronously = OPTIMIZE;
|
||||||
|
|
||||||
|
public FreedomChat freedomChat;
|
||||||
|
public class FreedomChat extends ConfigurationPart {
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Fri, 25 Oct 2024 19:11:40 +0900
|
||||||
|
Subject: [PATCH] Reset dirty flag when loading maps from the disk
|
||||||
|
|
||||||
|
Based on SparklyPaper, Copyright (C) 2024 SparklyPower
|
||||||
|
commit: c023b928439b9c71277f27cc9b5bd36ca32624ea
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
index 26da9e7c25ef6a89482838010d8ed6bcf8c87511..71aa3b9c5604f832e764e0d7a93da467ffe7dee1 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
@@ -209,6 +209,7 @@ public class MapItemSavedData extends SavedData {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.resetDirtyWhenLoadingMapsFromDisk) worldmap.setDirty(false); // Plazma - Reset dirty flag when loading maps from the disk
|
||||||
|
return worldmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
index a0b1239e302f0366743949a895a0539348817077..14ba63f5ef6ad5d96972b18e1174a8a94491fa57 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||||
|
@@ -130,6 +130,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||||
|
public Miscellaneous misc;
|
||||||
|
public class Miscellaneous extends ConfigurationPart {
|
||||||
|
|
||||||
|
+ public boolean resetDirtyWhenLoadingMapsFromDisk = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Fri, 25 Oct 2024 19:13:21 +0900
|
||||||
|
Subject: [PATCH] Allow throttling hopper checks if the target container is
|
||||||
|
full
|
||||||
|
|
||||||
|
Based on SparklyPaper, Copyright (C) 2024 SparklyPower.
|
||||||
|
commit: c023b928439b9c71277f27cc9b5bd36ca32624ea
|
||||||
|
|
||||||
|
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 5ebbdb94d9b91c442ff60eb6872f740ebd790fa0..aeeb8af68ea43ae6c93952610918d77b1593ed54 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
|
||||||
|
@@ -441,6 +441,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
Direction enumdirection = blockEntity.facing.getOpposite();
|
||||||
|
|
||||||
|
if (HopperBlockEntity.isFullContainer(iinventory, enumdirection)) {
|
||||||
|
+ if (world.plazmaConfig().block.hopper.fullCooldown != 0) blockEntity.setCooldown(world.plazmaConfig().block.hopper.fullCooldown); // Plazma - Allow throttling hopper checks if the target container is full
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// Paper start - Perf: Optimize Hoppers
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
index d366e8755ba91c329164c16659f6b07245577fba..f21ed3431fd8472c78c15578bbd12214c499ceea 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
@@ -64,6 +64,12 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||||
|
public Block block;
|
||||||
|
public class Block extends ConfigurationPart {
|
||||||
|
|
||||||
|
+ public Hopper hopper;
|
||||||
|
+ public class Hopper extends ConfigurationPart {
|
||||||
|
+
|
||||||
|
+ public int fullCooldown = 0;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: AlphaKR93 <dev@alpha93.kr>
|
||||||
|
Date: Fri, 13 Dec 2024 21:10:27 +0900
|
||||||
|
Subject: [PATCH] Port minor SparklyPaper patches
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||||
|
index 2bec5ed591e658765602379f9065b8089f5df6ea..ddcf301f098bbe55dbef7751180110a22bccc68d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||||
|
@@ -58,6 +58,7 @@ import org.bukkit.event.player.PlayerVelocityEvent;
|
||||||
|
|
||||||
|
public class ServerEntity {
|
||||||
|
|
||||||
|
+ public static boolean PLAZMA_DISTANCE_SQR = false; // Plazma - Port Minor SparklyPaper patches; Skip distanceToSqr if the delta is the same
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
private static final int TOLERANCE_LEVEL_ROTATION = 1;
|
||||||
|
private static final double TOLERANCE_LEVEL_POSITION = 7.62939453125E-6D;
|
||||||
|
@@ -232,6 +233,7 @@ public class ServerEntity {
|
||||||
|
|
||||||
|
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) {
|
||||||
|
Vec3 vec3d1 = this.entity.getDeltaMovement();
|
||||||
|
+ if (PLAZMA_DISTANCE_SQR || vec3d1 != this.lastSentMovement) { // Plazma - Port Minor SparklyPaper patches; Skip distanceToSqr if the delta is the same
|
||||||
|
double d0 = vec3d1.distanceToSqr(this.lastSentMovement);
|
||||||
|
|
||||||
|
if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) {
|
||||||
|
@@ -246,6 +248,7 @@ public class ServerEntity {
|
||||||
|
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ } // Plazma - Port Minor SparklyPaper patches; Skip distanceToSqr if the delta is the same
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packet1 != null) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
||||||
|
index da7e1a69ecb4e6b3be2d8544ac406aa519bd196e..ce56fdd0bbe1c95146c88594c68a6a399f01218e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
||||||
|
+++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
||||||
|
@@ -90,12 +90,14 @@ public class ServerStatsCounter extends StatsCounter {
|
||||||
|
this.dirty.add(stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* // Plazma - Port Minor SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
||||||
|
private Set<Stat<?>> getDirty() {
|
||||||
|
Set<Stat<?>> set = Sets.newHashSet(this.dirty);
|
||||||
|
|
||||||
|
this.dirty.clear();
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
+ */ // Plazma - Port Minor SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
||||||
|
|
||||||
|
public void parseLocal(DataFixer dataFixer, String json) {
|
||||||
|
try {
|
||||||
|
@@ -242,14 +244,12 @@ public class ServerStatsCounter extends StatsCounter {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendStats(ServerPlayer player) {
|
||||||
|
- Object2IntMap<Stat<?>> object2intmap = new Object2IntOpenHashMap();
|
||||||
|
- Iterator iterator = this.getDirty().iterator();
|
||||||
|
+ // Plazma start - Port Minor SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
||||||
|
+ Object2IntMap<Stat<?>> object2intmap = new Object2IntOpenHashMap<>();
|
||||||
|
+ for (final Stat<?> stat : this.dirty) object2intmap.put(stat, this.getValue(stat));
|
||||||
|
|
||||||
|
- while (iterator.hasNext()) {
|
||||||
|
- Stat<?> statistic = (Stat) iterator.next();
|
||||||
|
-
|
||||||
|
- object2intmap.put(statistic, this.getValue(statistic));
|
||||||
|
- }
|
||||||
|
+ this.dirty.clear();
|
||||||
|
+ // Plazma end - Port Minor SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
||||||
|
|
||||||
|
player.connection.send(new ClientboundAwardStatsPacket(object2intmap));
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||||
|
index 68a0aa6545c8aba3ecc31086a8d2bc3e1aada64e..4b9fbb4b1ad434ea06a44e30e66c394b07be7b7f 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||||
|
@@ -276,7 +276,12 @@ public class MapItem extends Item {
|
||||||
|
mapItemSavedData.tickCarriedBy(player, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!mapItemSavedData.locked && (selected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) {
|
||||||
|
+ // Plazma start - Port Minor SparklyPaper patches; Skip map update if the craft renderer is null
|
||||||
|
+ if (!mapItemSavedData.locked
|
||||||
|
+ && (!world.plazmaConfig().item.skipMapUpdateIfCraftRenderIsNull || mapItemSavedData.mapView.getRenderers().stream().anyMatch(renderer -> renderer instanceof org.bukkit.craftbukkit.map.CraftMapRenderer))
|
||||||
|
+ && (selected || entity instanceof Player player && player.getOffhandItem() == stack)
|
||||||
|
+ ) {
|
||||||
|
+ // Plazma end - Port Minor SparklyPaper patches; Skip map update if the craft renderer is null
|
||||||
|
this.update(world, entity, mapItemSavedData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
||||||
|
index 8149b9c51b78eb5c689b7218a2ca3aab60e73bcf..125a4f13dbe98976c4cf94bb523463a51bd4f8dd 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
||||||
|
@@ -145,7 +145,7 @@ public class CraftMapColorCache implements MapPalette.MapColorCache {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- public boolean isCached() {
|
||||||
|
+ public synchronized boolean isCached() { // Plazma - Port Minor SparklyPaper patches; Fix concurrency issues when using "imageToBytes" in multiple threads
|
||||||
|
return this.cached || (!this.running.get() && this.initCache().isDone());
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
index bbb51ccf2016987202811ee893f855da2612dd17..f6f372644bca9111aa3f45bf7ae8e66e53d11505 100644
|
||||||
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||||
|
@@ -86,6 +86,8 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||||
|
public Item item;
|
||||||
|
public class Item extends ConfigurationPart {
|
||||||
|
|
||||||
|
+ public boolean skipMapUpdateIfCraftRenderIsNull = true;
|
||||||
|
+
|
||||||
|
public ShootableFireCharge shootableFireCharge;
|
||||||
|
public class ShootableFireCharge extends ConfigurationPart {
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user