Compare commits
133 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c618748c6 | ||
|
|
f63cf7c1fa | ||
|
|
ea9ab3f27c | ||
|
|
ae5526ff76 | ||
|
|
f6f2314be6 | ||
|
|
4e5feda68f | ||
|
|
b6729158b0 | ||
|
|
d4cd2cf5b3 | ||
|
|
c4741b284e | ||
|
|
65ee54da34 | ||
|
|
7ebfac20b8 | ||
|
|
fa210d634d | ||
|
|
91eaf9966d | ||
|
|
3bc1986806 | ||
|
|
3f3c9292bf | ||
|
|
6a994e5d50 | ||
|
|
034cf1e6d6 | ||
|
|
118cabf45c | ||
|
|
5562bd750f | ||
|
|
cedc442598 | ||
|
|
35983edbd3 | ||
|
|
8664b137ca | ||
|
|
94d5a28cc4 | ||
|
|
76890444db | ||
|
|
08dd766899 | ||
|
|
7fb8ff8fd0 | ||
|
|
32e02629a9 | ||
|
|
ef8af2f22a | ||
|
|
23b264963e | ||
|
|
95e8ffed83 | ||
|
|
e2b32c0b66 | ||
|
|
12d82f3aa5 | ||
|
|
e7b45be456 | ||
|
|
48a3fc55b7 | ||
|
|
29b6a8d59d | ||
|
|
f7a4bb691b | ||
|
|
34724b4471 | ||
|
|
660e911bbb | ||
|
|
092e4ddbd8 | ||
|
|
7fd3f17095 | ||
|
|
53fdedd162 | ||
|
|
e0f78402c8 | ||
|
|
d36d0dc5fc | ||
|
|
f6246f3349 | ||
|
|
b35f17f3e6 | ||
|
|
bc3c1437a0 | ||
|
|
1f2930b604 | ||
|
|
602212daff | ||
|
|
152dbba7b0 | ||
|
|
757de4f65f | ||
|
|
af98564be2 | ||
|
|
4d29274175 | ||
|
|
1c59e62414 | ||
|
|
d0103df33b | ||
|
|
34977e4e8a | ||
|
|
d2d7c120e5 | ||
|
|
7239362b4d | ||
|
|
83dc76521c | ||
|
|
51e1e75382 | ||
|
|
86c3a4e8de | ||
|
|
c40c8785cd | ||
|
|
e3a38f51cf | ||
|
|
a3812b6cef | ||
|
|
b8868beac9 | ||
|
|
835c7b10d8 | ||
|
|
e7823d7a0a | ||
|
|
e44b800bbe | ||
|
|
5705d55587 | ||
|
|
3c013f180c | ||
|
|
b5121bd590 | ||
|
|
2ac15d9c21 | ||
|
|
eafa041f07 | ||
|
|
89828085c6 | ||
|
|
9c397142c6 | ||
|
|
7e1ad9e37a | ||
|
|
d844c7c954 | ||
|
|
292f587834 | ||
|
|
cd442cc16b | ||
|
|
e6207392bf | ||
|
|
e817028ac1 | ||
|
|
ae74a9bb2c | ||
|
|
fc5216a070 | ||
|
|
2deb7e54f0 | ||
|
|
61e11ce710 | ||
|
|
f935b6ffd5 | ||
|
|
d09ea5c71c | ||
|
|
063da21ea3 | ||
|
|
0ec98213bf | ||
|
|
1a2f815bcf | ||
|
|
e58f00dded | ||
|
|
7d9b65d3d4 | ||
|
|
3afafc910b | ||
|
|
a4fdc32a0b | ||
|
|
6150eef35c | ||
|
|
b516d47aeb | ||
|
|
4dfd98f9b9 | ||
|
|
ac5e38e86e | ||
|
|
dbbc862af3 | ||
|
|
784e2baf7a | ||
|
|
94ca13f790 | ||
|
|
963286ac7e | ||
|
|
0383ff6961 | ||
|
|
8e1bfd6c3c | ||
|
|
1638fe6b97 | ||
|
|
d5699419e4 | ||
|
|
d57758c9f8 | ||
|
|
63d893a0e4 | ||
|
|
08892016f5 | ||
|
|
32ac7246a3 | ||
|
|
4caf0ff2bd | ||
|
|
d4ca1a3765 | ||
|
|
842d7fa834 | ||
|
|
ecad700a9e | ||
|
|
1190cfc22a | ||
|
|
0284282d7f | ||
|
|
229675335e | ||
|
|
620e5d7176 | ||
|
|
41dd32edac | ||
|
|
a32479ac64 | ||
|
|
cf6cc82ebc | ||
|
|
6c6f02d305 | ||
|
|
12f555aa4d | ||
|
|
2d37d7141c | ||
|
|
363fcaec61 | ||
|
|
a7419fafc9 | ||
|
|
c06b0d77a1 | ||
|
|
f07107ec59 | ||
|
|
3ef59980e7 | ||
|
|
e2af449239 | ||
|
|
41c0116446 | ||
|
|
ffbcddccac | ||
|
|
1e2bebf45f | ||
|
|
80f5d58780 |
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@@ -1,20 +1,22 @@
|
||||
name: Generate Jars
|
||||
on: [ push, pull_request ]
|
||||
env:
|
||||
version: '1.19.3'
|
||||
branch: ver/1.19.3
|
||||
version: '1.19.4'
|
||||
branch: ver/1.19.4
|
||||
jobs:
|
||||
paperclip:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2.5.0
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '17'
|
||||
cache: 'gradle'
|
||||
distribution: 'temurin'
|
||||
distribution: 'GraalVM'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: 'latest'
|
||||
- name: Configure Git User Details
|
||||
run: |
|
||||
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||
|
||||
14
.github/workflows/release.yml
vendored
14
.github/workflows/release.yml
vendored
@@ -1,20 +1,22 @@
|
||||
name: Release Jars
|
||||
on: workflow_dispatch
|
||||
on: [push, workflow_dispatch]
|
||||
env:
|
||||
version: '1.19.3'
|
||||
branch: ver/1.19.3
|
||||
version: '1.19.4'
|
||||
branch: ver/1.19.4
|
||||
jobs:
|
||||
paperclip:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2.5.0
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '17'
|
||||
cache: 'gradle'
|
||||
distribution: 'temurin'
|
||||
distribution: 'GraalVM'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: 'latest'
|
||||
- name: Configure Git User Details
|
||||
run: |
|
||||
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||
|
||||
10
.github/workflows/upstream.yml
vendored
10
.github/workflows/upstream.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Update Upstream (Purpur)
|
||||
name: Update Upstream (Folia)
|
||||
|
||||
on:
|
||||
schedule:
|
||||
@@ -7,9 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
upstream:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v2
|
||||
@@ -22,7 +20,7 @@ jobs:
|
||||
- name: Configure Git User Details
|
||||
run: git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||
- name: Update Upstream Commit Hash
|
||||
run: ./gradlew purpurRefLatest --stacktrace
|
||||
run: ./gradlew foliaRefLatest --stacktrace
|
||||
- name: Apply Patches
|
||||
run: ./gradlew applyPatches --stacktrace
|
||||
- name: Build Paperclip jar
|
||||
@@ -37,8 +35,8 @@ jobs:
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
commit-message: Update Upstream (Purpur)
|
||||
commit-message: Update Upstream (Folia)
|
||||
branch: update-upstream
|
||||
delete-branch: true
|
||||
title: 'Update Upstream (Purpur)'
|
||||
title: 'Update Upstream (Folia)'
|
||||
body: ''
|
||||
|
||||
51
README.md
51
README.md
@@ -2,8 +2,7 @@
|
||||
<div align="center">
|
||||
<img src="https://github.com/kugge/Kaiiju/blob/ver/1.19.3/logo.png?" width="32%" height="32%"/>
|
||||
<h1>Kaiiju</h1>
|
||||
<h3>A Server Software Designed For Anarchy</h3>
|
||||
<h4>❗ [ Warning ] Work in progress, contributions are welcome ❗</h4>
|
||||
<h3>Folia fork, designed for vanilla/anarchy servers</h3>
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/kugge/Kaiiju/actions)
|
||||
@@ -13,12 +12,47 @@
|
||||
|
||||
## Features
|
||||
|
||||
### Additions
|
||||
- **Xymb Linear Format**: Saves about 50% of disk space in OW and Nether and 95% in The End.
|
||||
- **Lobotomize**: Lobotomize mobs and villagers without breaking vanilla mechanics.
|
||||
### Primary
|
||||
- **Xymb Linear Format**: Saves about 50% of disk space in OW/Nether and 95% in The End.
|
||||
- **Auto update**: Automatic upstream updates.
|
||||
|
||||
### Notable
|
||||
- **Optimize Hopper**: Enable/Disable Paper "Optimize Hopper" patch that break a lot of redstone farms.
|
||||
- **Fix void trading**: Enable/Disable void trading.
|
||||
|
||||
### Configuration
|
||||
|
||||
```yaml
|
||||
verbose: false
|
||||
gameplay:
|
||||
server-mod-name: Kaiiju
|
||||
network:
|
||||
send-null-entity-packets: true
|
||||
alternate-keepalive: false
|
||||
region-format:
|
||||
debug: false
|
||||
world-settings:
|
||||
default:
|
||||
gameplay:
|
||||
shulker-box-drop-contents-when-destroyed: true
|
||||
fix-void-trading: true
|
||||
optimize-hoppers: true
|
||||
region-format:
|
||||
format: LINEAR
|
||||
linear:
|
||||
compression-level: 1
|
||||
crash-on-broken-symlink: true
|
||||
config-version: 1
|
||||
```
|
||||
Documentation: [Kaiiju Wiki](https://github.com/KaiijuMC/Kaiiju/wiki/Configuration)
|
||||
|
||||
### Roadmap
|
||||
- **Static view distance**: Reduce RAM usage / Region size with a "static" view distance.
|
||||
- **Linear timestamps**: Add chunk timestamps to linear region files.
|
||||
- **Native world conversion**: Convert region file format at startup.
|
||||
- **Stash deduplication**: Make giant dupe stashes possible and lagless.
|
||||
|
||||
## Building
|
||||
In order to distribute and use this server software, you need a paperclip file:
|
||||
|
||||
```bash
|
||||
./gradlew applyPatches # Apply Kaiiju patches
|
||||
@@ -26,7 +60,4 @@ In order to distribute and use this server software, you need a paperclip file:
|
||||
```
|
||||
|
||||
## License
|
||||
Patches are licensed under GPL-3.0.
|
||||
All other files are licensed under MIT.
|
||||
|
||||
Made with <span style="color: #e25555;">♥</span> on Earth.
|
||||
Original patches are licensed under GPL-3.0.
|
||||
|
||||
108
build.gradle.kts
108
build.gradle.kts
@@ -3,26 +3,12 @@ import io.papermc.paperweight.util.constants.*
|
||||
|
||||
plugins {
|
||||
java
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
id("io.papermc.paperweight.patcher") version "1.4.1"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://papermc.io/repo/repository/maven-public/") {
|
||||
content { onlyForConfigurations(PAPERCLIP_CONFIG) }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
decompiler("net.minecraftforge:forgeflower:2.0.605.1")
|
||||
paperclip("io.papermc:paperclip:3.0.2")
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("io.papermc.paperweight.patcher") version "1.5.4"
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "maven-publish")
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
@@ -31,8 +17,25 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl) {
|
||||
content {
|
||||
onlyForConfigurations(PAPERCLIP_CONFIG)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
decompiler("net.minecraftforge:forgeflower:2.0.629.0")
|
||||
paperclip("io.papermc:paperclip:3.0.3")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
tasks.withType<JavaCompile> {
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
}
|
||||
@@ -42,15 +45,9 @@ subprojects {
|
||||
tasks.withType<ProcessResources> {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://oss.sonatype.org/content/groups/public/")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://ci.emc.gs/nexus/content/groups/aikar/")
|
||||
maven("https://repo.aikar.co/content/groups/aikar")
|
||||
maven("https://repo.md-5.net/content/repositories/releases/")
|
||||
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
|
||||
maven(paperMavenPublicUrl)
|
||||
maven("https://jitpack.io")
|
||||
}
|
||||
}
|
||||
@@ -58,53 +55,52 @@ subprojects {
|
||||
paperweight {
|
||||
serverProject.set(project(":kaiiju-server"))
|
||||
|
||||
remapRepo.set("https://maven.fabricmc.net/")
|
||||
decompileRepo.set("https://maven.quiltmc.org")
|
||||
remapRepo.set(paperMavenPublicUrl)
|
||||
decompileRepo.set(paperMavenPublicUrl)
|
||||
|
||||
useStandardUpstream("Purpur") {
|
||||
url.set(github("PurpurMC", "Purpur"))
|
||||
ref.set(providers.gradleProperty("purpurRef"))
|
||||
useStandardUpstream("Folia") {
|
||||
url.set(github("PaperMC", "Folia"))
|
||||
ref.set(providers.gradleProperty("foliaRef"))
|
||||
|
||||
withStandardPatcher {
|
||||
apiSourceDirPath.set("Purpur-API")
|
||||
baseName("Folia")
|
||||
|
||||
apiPatchDir.set(layout.projectDirectory.dir("patches/api"))
|
||||
apiOutputDir.set(layout.projectDirectory.dir("kaiiju-api"))
|
||||
|
||||
serverSourceDirPath.set("Purpur-Server")
|
||||
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
||||
serverOutputDir.set(layout.projectDirectory.dir("kaiiju-server"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("purpurRefLatest") {
|
||||
// Update the paperRef in gradle.properties to be the latest commit.3
|
||||
val tempDir = layout.cacheDir("purpurRefLatest");
|
||||
val file = "gradle.properties";
|
||||
tasks.register("foliaRefLatest") {
|
||||
// Update the foliaRef in gradle.properties to be the latest commit.
|
||||
val tempDir = layout.cacheDir("foliaRefLatest");
|
||||
val file = "gradle.properties";
|
||||
|
||||
doFirst {
|
||||
data class GithubCommit(
|
||||
val sha: String
|
||||
)
|
||||
doFirst {
|
||||
data class GithubCommit(
|
||||
val sha: String
|
||||
)
|
||||
|
||||
val purpurLatestCommitJson = layout.cache.resolve("purpurLatestCommit.json");
|
||||
download.get().download("https://api.github.com/repos/PurpurMC/Purpur/commits/ver/1.19.3", purpurLatestCommitJson);
|
||||
val purpurLatestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(purpurLatestCommitJson)["sha"].asString;
|
||||
val foliaLatestCommitJson = layout.cache.resolve("foliaLatestCommit.json");
|
||||
download.get().download("https://api.github.com/repos/PaperMC/Folia/commits/master", foliaLatestCommitJson);
|
||||
val foliaLatestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(foliaLatestCommitJson)["sha"].asString;
|
||||
|
||||
copy {
|
||||
from(file)
|
||||
into(tempDir)
|
||||
filter { line: String ->
|
||||
line.replace("purpurRef = .*".toRegex(), "purpurRef = $purpurLatestCommit")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doLast {
|
||||
copy {
|
||||
from(tempDir.file("gradle.properties"))
|
||||
into(project.file(file).parent)
|
||||
copy {
|
||||
from(file)
|
||||
into(tempDir)
|
||||
filter { line: String ->
|
||||
line.replace("foliaRef = .*".toRegex(), "foliaRef = $foliaLatestCommit")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doLast {
|
||||
copy {
|
||||
from(tempDir.file("gradle.properties"))
|
||||
into(project.file(file).parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
group = dev.kugge.kaiiju
|
||||
version = 1.19.3-R0.1-SNAPSHOT
|
||||
mcVersion = 1.19.3
|
||||
group = dev.kaiijumc.kaiiju
|
||||
version = 1.19.4-R0.1-SNAPSHOT
|
||||
mcVersion = 1.19.4
|
||||
|
||||
purpurRef = 08aa4dccaad7e5d31ca51b53489d2d413e49748d
|
||||
foliaRef = b97116b7b2236ca422150d93de5fd1fc8f08de17
|
||||
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.vfs.watch=false
|
||||
org.gradle.jvmargs=-Xmx4G -Dfile.encoding=UTF-8 -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true -Dgraal.SpeculativeGuardMovement=true -Dgraal.WriteableCodeCache=true
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
288
gradlew
vendored
288
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,67 +17,98 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -87,9 +118,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -98,7 +129,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -106,80 +137,109 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,8 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
BIN
logo.png
BIN
logo.png
Binary file not shown.
|
Before Width: | Height: | Size: 4.3 MiB After Width: | Height: | Size: 879 KiB |
@@ -5,12 +5,12 @@ Subject: [PATCH] Kaiiju Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index e0f69edf603c2ec99bc92b16b18912272cc41bd9..b2c8c18437537eb2ea91bdeb9f715e01a182fbcb 100644
|
||||
index c230a10aff36f6b484d7e3963cbf8073f8676fb1..6b17fc3c788b745aa458eee82cace12e4728b6b5 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -1983,6 +1983,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
@@ -1971,6 +1971,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
}
|
||||
// Purpur end
|
||||
// Paper end
|
||||
|
||||
+ // Kaiiju start
|
||||
+ @NotNull
|
||||
|
||||
@@ -5,222 +5,226 @@ Subject: [PATCH] Kaiiju Rebranding
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 020927dfe9624453311d1d171a10f44344ec8710..c6a4c48b14a8c927284720b79b93ee1aa9df7da6 100644
|
||||
index dd53b1ffaff8dbaea0cf21c489a90162a496a026..6dd416f65755ca0542e6661b8716672264120d59 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
@@ -8,7 +8,7 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
- implementation(project(":purpur-api")) // Purpur
|
||||
+ implementation(project(":kaiiju-api")) // Purpur // Kaiiju
|
||||
// Pufferfish start
|
||||
// Folia start
|
||||
- implementation(project(":folia-api"))
|
||||
+ implementation(project(":kaiiju-api")) // Kaiiju
|
||||
implementation("io.papermc.paper:paper-mojangapi:1.19.3-R0.1-SNAPSHOT") {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
@@ -83,7 +83,7 @@ tasks.jar {
|
||||
}
|
||||
@@ -66,7 +66,7 @@ tasks.jar {
|
||||
attributes(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
"Implementation-Title" to "CraftBukkit",
|
||||
- "Implementation-Version" to "git-Purpur-$implementationVersion", // Purpur
|
||||
+ "Implementation-Version" to "git-Kaiiju-$implementationVersion", // Purpur // Kaiiju
|
||||
- "Implementation-Version" to "git-Folia-$implementationVersion", // Folia
|
||||
+ "Implementation-Version" to "git-Kaiiju-$implementationVersion", // Folia // Kaiiju
|
||||
"Implementation-Vendor" to date, // Paper
|
||||
"Specification-Title" to "Bukkit",
|
||||
"Specification-Version" to project.version,
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
index 9713263c3bd34ab8a3bfc0a8797ba0b1b88ed733..0b95cd5305e4559d6dca59011869e5b203d51576 100644
|
||||
index 58dc84b7b3b04c2d0b00fc5fac5303d3378b3467..a128b1fabd4aadfe26a8375903c0451d7a65983a 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()); // Purpur
|
||||
+ Metrics metrics = new Metrics("Kaiiju", serverUUID, logFailedRequests, Bukkit.getLogger()); // Purpur // Kaiiju
|
||||
- Metrics metrics = new Metrics("Folia", serverUUID, logFailedRequests, Bukkit.getLogger()); // Folia - we have our own bstats page
|
||||
+ Metrics metrics = new Metrics("Kaiiju", serverUUID, logFailedRequests, Bukkit.getLogger()); // Folia - we have our own bstats page // Kaiiju
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
String minecraftVersion = Bukkit.getVersion();
|
||||
@@ -603,7 +603,7 @@ public class Metrics {
|
||||
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() ? "bungee" : "offline"))); // Purpur
|
||||
- metrics.addCustomChart(new Metrics.SimplePie("purpur_version", () -> (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown")); // Purpur
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("kaiiju_version", () -> (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown")); // Purpur // Kaiiju
|
||||
@@ -612,6 +612,7 @@ public class Metrics {
|
||||
paperVersion = "unknown";
|
||||
}
|
||||
metrics.addCustomChart(new Metrics.SimplePie("folia_version", () -> paperVersion)); // Folia - we have our own bstats page
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("kaiiju_version", () -> (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown")); // Kaiiju
|
||||
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
index fba5dbdb7bcbb55400ef18342c9b54612972a718..c94e00290e21e4bcfac5b137ded704c0848463cc 100644
|
||||
index 719b0e318a85d4a1fb8f616deeb31193495b462e..751b2bc79d29cb21c38cf5d35e3711149ec7b011 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
@@ -20,7 +20,7 @@ import java.util.stream.StreamSupport;
|
||||
@@ -19,10 +19,11 @@ import java.util.stream.StreamSupport;
|
||||
|
||||
public class PaperVersionFetcher implements VersionFetcher {
|
||||
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||
// Purpur start
|
||||
- private static final String DOWNLOAD_PAGE = "https://purpurmc.org/downloads";
|
||||
+ private static final String DOWNLOAD_PAGE = "https://github.com/KaiijuMC/Kaiiju/releases"; // Kaiiju
|
||||
private static int distance = -2; public int distance() { return distance; }
|
||||
// Purpur end
|
||||
- private static final String GITHUB_BRANCH_NAME = "master";
|
||||
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
|
||||
+ // Kaiiju start
|
||||
+ private static final String DOWNLOAD_PAGE = "https://github.com/KaiijuMC/Kaiiju/releases";
|
||||
+ private static int distance = -2; public int distance() { return distance; }
|
||||
+ // Kaiiju end
|
||||
private static @Nullable String mcVer;
|
||||
@@ -33,8 +33,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
-
|
||||
@Override
|
||||
public long getCacheTime() {
|
||||
return 720000;
|
||||
@@ -31,8 +32,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||
- String[] parts = serverVersion.substring("git-Purpur-".length()).split("[-\\s]"); // Purpur
|
||||
- final Component updateMessage = getUpdateStatusMessage("PurpurMC/Purpur", "ver/" + getMinecraftVersion(), parts[0]); // Purpur
|
||||
+ String[] parts = serverVersion.substring("git-Kaiiju-".length()).split("[-\\s]"); // Purpur // Kaiiju
|
||||
+ final Component updateMessage = getUpdateStatusMessage("KaiijuMC/Kaiiju", "ver/" + getMinecraftVersion(), parts[0]); // Purpur // Kaiiju
|
||||
- String[] parts = serverVersion.substring("git-Folia-".length()).split("[-\\s]"); // Folia
|
||||
- final Component updateMessage = getUpdateStatusMessage("PaperMC/Folia", GITHUB_BRANCH_NAME, parts[0]); // Folia
|
||||
+ String[] parts = serverVersion.substring("git-Kaiiju-".length()).split("[-\\s]"); // Folia // Kaiiju
|
||||
+ final Component updateMessage = getUpdateStatusMessage("KaiijuMC/Kaiiju", "ver/" + getMinecraftVersion(), parts[0]); // Folia // Kaiiju
|
||||
final Component history = getHistory();
|
||||
|
||||
return history != null ? Component.join(net.kyori.adventure.text.JoinConfiguration.separator(Component.newline()), history, updateMessage) : updateMessage; // Purpur
|
||||
@@ -47,7 +47,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
||||
@@ -45,7 +46,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
String result = matcher.group();
|
||||
mcVer = result.substring(0, result.length() - 2); // strip 'R' anchor and trailing '-'
|
||||
} else {
|
||||
- org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to Purpur!"); // Purpur
|
||||
+ org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to Kaiiju!"); // Purpur // Kaiiju
|
||||
- org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to PaperMC!");
|
||||
+ org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to KaiijuMC!"); // Kaiiju
|
||||
org.bukkit.Bukkit.getLogger().warning("Pattern: " + VER_PATTERN.toString());
|
||||
org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion());
|
||||
}
|
||||
@@ -58,13 +58,15 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
@@ -56,6 +57,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
|
||||
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||
//int distance; // Purpur - use field
|
||||
+ /* // Kaiiju
|
||||
int distance;
|
||||
+ // Kaiiju start - disable jenkins/api checking
|
||||
+ /*
|
||||
try {
|
||||
int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||
distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
|
||||
} catch (NumberFormatException ignored) {
|
||||
+ */ // Kaiiju
|
||||
@@ -63,6 +66,10 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
versionInfo = versionInfo.replace("\"", "");
|
||||
distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||
- }
|
||||
+ //} // Kaiiju
|
||||
}
|
||||
+ */
|
||||
+ versionInfo = versionInfo.replace("\"", "");
|
||||
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||
+ // Kaiiju end
|
||||
|
||||
switch (distance) {
|
||||
case -1:
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
index 3cb56595822799926a8141e60a42f5d1edfc6de5..7ae1c10ebfb8b61e7d0fa63c96ff2dee98294f4d 100644
|
||||
index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..1c7b5d91e914efbcfb50c6137c7760787e38ad94 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
@@ -17,7 +17,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
|
||||
@Override
|
||||
protected LineReader buildReader(LineReaderBuilder builder) {
|
||||
builder
|
||||
- .appName("Purpur") // Purpur
|
||||
+ .appName("Kaiiju") // Purpur // Kaiiju
|
||||
- .appName("Paper")
|
||||
+ .appName("Kaiiju") // Kaiiju
|
||||
.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/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java
|
||||
index b5b6657e52e4f7a630229bd3ba433438af293e22..afda0d4198398de29a62159fae701b222969e9fa 100644
|
||||
index abe37c7c3c6f5ab73afd738ec78f06d7e4d2ed96..52fc6bb99f6024273c7438d01314b576da66bd1a 100644
|
||||
--- a/src/main/java/net/minecraft/CrashReport.java
|
||||
+++ b/src/main/java/net/minecraft/CrashReport.java
|
||||
@@ -125,7 +125,7 @@ public class CrashReport {
|
||||
stringbuilder.append("---- Minecraft Crash Report ----\n");
|
||||
// Purpur start
|
||||
stringbuilder.append("// ");
|
||||
- stringbuilder.append("// DO NOT REPORT THIS TO PAPER! REPORT TO PURPUR INSTEAD!");
|
||||
+ stringbuilder.append("// DO NOT REPORT THIS TO PAPER/PURPUR! REPORT TO KAIIJU INSTEAD!"); // Kaiiju
|
||||
// Purpur end
|
||||
stringbuilder.append("// ");
|
||||
stringbuilder.append(CrashReport.getErrorComment());
|
||||
- stringbuilder.append("\n\n");
|
||||
+ stringbuilder.append("// DO NOT REPORT THIS TO PAPER/FOLIA! REPORT TO KAIIJU INSTEAD!"); // Kaiiju
|
||||
stringbuilder.append("Time: ");
|
||||
stringbuilder.append(CrashReport.DATE_TIME_FORMATTER.format(ZonedDateTime.now()));
|
||||
stringbuilder.append("\n");
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index cea4447aad2d64db56a76e4ba180dc7326d2e13b..40b4bd2f1a61c2d9a59c9c09b72713401969460b 100644
|
||||
index f5721f6d719b7055fdccc81d5e67ed758e90cb10..0696ad97437726fd6a13badfe7db0617dfbfb1ad 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -927,7 +927,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -999,7 +999,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
shutdownThread = Thread.currentThread();
|
||||
org.spigotmc.WatchdogThread.doStop(); // Paper
|
||||
if (!isSameThread()) {
|
||||
- MinecraftServer.LOGGER.info("Stopping main thread (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO PURPUR)"); // Purpur
|
||||
+ MinecraftServer.LOGGER.info("Stopping main thread (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO KAIIJU)"); // Purpur // Kaiiju
|
||||
if (false && !isSameThread()) { // Folia - region threading
|
||||
- MinecraftServer.LOGGER.info("Stopping main thread (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO PAPER)");
|
||||
+ MinecraftServer.LOGGER.info("Stopping main thread (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO KAIIJU)"); // Kaiiju
|
||||
while (this.getRunningThread().isAlive()) {
|
||||
this.getRunningThread().stop();
|
||||
try {
|
||||
@@ -1833,7 +1833,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Folia"; // Folia - Folia > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
+ return "Kaiiju"; // Kaiiju - Kaiiju > // Folia - Folia > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 4a8aafd341fdad4b5ae326c4759b3381f5061fb5..caf1237491649205f7b3c7ea4fe1d31d567bbafe 100644
|
||||
index 32c9b38036052649b7b5fb25d7c4a49fdd1ca972..176f3acec268dad80cc90029edd88e7a0c3e8885 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -262,7 +262,7 @@ import javax.annotation.Nullable; // Paper
|
||||
@@ -256,7 +256,7 @@ import javax.annotation.Nullable; // Paper
|
||||
import javax.annotation.Nonnull; // Paper
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
- private final String serverName = "Purpur"; // Paper // Purpur
|
||||
+ private final String serverName = "Kaiiju"; // Paper // Purpur // Kaiiju
|
||||
- private final String serverName = "Folia"; // Folia // Paper
|
||||
+ private final String serverName = "Kaiiju"; // Kaiiju // Folia // Paper
|
||||
private final String serverVersion;
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 78ac748859e21a61140e9bff67e4527a8d35b4b6..5e14153433f5c7854a357aad4776b2aad4cd6fa0 100644
|
||||
index bd115a08512e6f4c13bc30ce2b05c7378754754f..d1b0483448a42f2d790eae353904bf6890178e1b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -883,7 +883,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
@@ -891,7 +891,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
return EntityCategory.WATER;
|
||||
}
|
||||
|
||||
- throw new UnsupportedOperationException("Unsupported monster type: " + type + ". This is a bug, report this to Purpur."); // Purpur
|
||||
+ throw new UnsupportedOperationException("Unsupported monster type: " + type + ". This is a bug, report this to Kaiiju."); // Purpur // Kaiiju
|
||||
- throw new UnsupportedOperationException("Unsupported monster type: " + type + ". This is a bug, report this to Spigot.");
|
||||
+ throw new UnsupportedOperationException("Unsupported monster type: " + type + ". This is a bug, report this to Kaiiju."); // Kaiiju
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index 5402098dce0d64d3dceea51f248d7d366850a74f..2b7a67c339994c34296f7057ffc8822b4aa0036b 100644
|
||||
index 9136fb30db749737e9f189d0901024fcad02e402..ac23657071ac5eb951706374ee16a4274728c5bd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -504,7 +504,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 Kaiiju"); // Paper // Purpur // Kaiiju
|
||||
- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Paper"); // Paper
|
||||
+ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Kaiiju"); // Paper // Kaiiju
|
||||
// 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 fb87620c742ff7912f5e8ccd2a7930dd605576d9..0f56013165cd61023b4f30a4da424b701e14a8e2 100644
|
||||
index e9b6ca3aa25e140467ae866d572483050ea3fa0e..5df2b0fceebaaa863f4f143c8f29e808b7f0c49b 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"); // Purpur
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/dev.kaiijumc.kaiiju/kaiiju-api/pom.properties"); // Purpur // Kaiiju
|
||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/dev.folia/folia-api/pom.properties"); // Folia
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/dev.kaiijumc.kaiiju/kaiiju-api/pom.properties"); // Folia // Kaiiju
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index c7c0ed8dfe58c841faf684a1fe228eeda6cd57b7..410ce2dc98c48871d2ddfb0195f2885adc18cba8 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -227,7 +227,7 @@ public class PurpurConfig {
|
||||
deathMessageOnlyBroadcastToAffectedPlayer = getBoolean("settings.broadcasts.death.only-broadcast-to-affected-player", deathMessageOnlyBroadcastToAffectedPlayer);
|
||||
}
|
||||
|
||||
- public static String serverModName = "Purpur";
|
||||
+ public static String serverModName = "Kaiiju"; // Kaiiju
|
||||
private static void serverModName() {
|
||||
serverModName = getString("settings.server-mod-name", serverModName);
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
index a810bfd3b8d6bd4d8f2ef8797e4281ae4fe8a67f..7e92d77edb448f2ec818bf4b876d3df56d6362cc 100644
|
||||
index e9fa7faaa4451e36b3908cbcbbe0baf213abde96..eea30035f7ce41f8f3c60afbbd255ae42166a306 100644
|
||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
@@ -155,14 +155,14 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
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 Kaiiju bug." ); // Paper // Purpur // Kaiiju
|
||||
- log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper
|
||||
+ log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Kaiiju bug." ); // Paper // Kaiiju
|
||||
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 Kaiiju bug, please report this to https://github.com/KaiijuMC/Kaiiju/issues" ); // Purpur // Kaiiju
|
||||
- log.log( Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" );
|
||||
+ log.log( Level.SEVERE, "If you are unsure or still think this is a Kaiiju bug, please report this to https://github.com/KaiijuMC/Kaiiju/issues" ); // Kaiiju
|
||||
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, "Kaiiju version: " + Bukkit.getServer().getVersion() ); // Purpur // Kaiiju
|
||||
- log.log( Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion() );
|
||||
+ log.log( Level.SEVERE, "Kaiiju version: " + Bukkit.getServer().getVersion() ); // Kaiiju
|
||||
//
|
||||
if ( net.minecraft.world.level.Level.lastPhysicsProblem != null )
|
||||
{
|
||||
@@ -228,14 +232,14 @@ index a810bfd3b8d6bd4d8f2ef8797e4281ae4fe8a67f..7e92d77edb448f2ec818bf4b876d3df5
|
||||
// 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 KAIIJU - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Purpur // Kaiiju
|
||||
- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---");
|
||||
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO KAIIJU - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Kaiiju
|
||||
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 Kaiiju!):" ); // Paper // Purpur // Kaiiju
|
||||
- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
|
||||
+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Kaiiju!):" ); // Paper // Kaiiju
|
||||
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system
|
||||
this.dumpTickingInfo(); // Paper - log detailed tick information
|
||||
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
|
||||
@@ -243,8 +247,8 @@ index a810bfd3b8d6bd4d8f2ef8797e4281ae4fe8a67f..7e92d77edb448f2ec818bf4b876d3df5
|
||||
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 KAIIJU - THIS IS NOT A BUG OR A CRASH ---"); // Purpur // Kaiiju
|
||||
- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---");
|
||||
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO KAIIJU - THIS IS NOT A BUG OR A CRASH ---"); // Kaiiju
|
||||
}
|
||||
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Kaiiju Configuration
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f935f5f2883
|
||||
index 0000000000000000000000000000000000000000..7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -0,0 +1,193 @@
|
||||
@@ -0,0 +1,195 @@
|
||||
+package dev.kaiijumc.kaiiju;
|
||||
+
|
||||
+import com.google.common.base.Throwables;
|
||||
@@ -27,6 +27,7 @@ index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f93
|
||||
+import java.lang.reflect.InvocationTargetException;
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
@@ -37,7 +38,8 @@ index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f93
|
||||
+ protected static final String HEADER = "This is the main configuration file for Kaiiju.\n"
|
||||
+ + "Some options may impact gameplay, so use with caution.\n"
|
||||
+ + "If you need help or have any questions related to Kaiiju,\n"
|
||||
+ + "Join our Discord server: https://discord.com/invite/qagZRAepb7";
|
||||
+ + "Join our Discord server: https://discord.com/invite/qagZRAepb7\n"
|
||||
+ + "Documentation: https://github.com/KaiijuMC/Kaiiju/wiki/Configuration";
|
||||
+ protected static File CONFIG_FILE;
|
||||
+ public static YamlConfiguration config;
|
||||
+
|
||||
@@ -203,7 +205,6 @@ index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f93
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19
|
||||
@@ -338,10 +339,10 @@ index 0000000000000000000000000000000000000000..dd4c3ca77acb3aeefc69b8eb948b8b20
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java b/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0dde8879856f8882f2840b4b8bfb5aa0b3f06b91
|
||||
index 0000000000000000000000000000000000000000..08a2375b90a2088e2bdfb3e316144677346a3dd6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
||||
@@ -0,0 +1,68 @@
|
||||
@@ -0,0 +1,67 @@
|
||||
+package dev.kaiijumc.kaiiju.command;
|
||||
+
|
||||
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
||||
@@ -395,7 +396,6 @@ index 0000000000000000000000000000000000000000..0dde8879856f8882f2840b4b8bfb5aa0
|
||||
+ KaiijuConfig.reload((File) console.options.valueOf("kaiiju-settings"));
|
||||
+ for (ServerLevel level : console.getAllLevels()) {
|
||||
+ level.kaiijuConfig.reload();
|
||||
+ level.resetBreedingCooldowns();
|
||||
+ }
|
||||
+ console.server.reloadCount++;
|
||||
+
|
||||
@@ -412,198 +412,82 @@ index 0000000000000000000000000000000000000000..0dde8879856f8882f2840b4b8bfb5aa0
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 46858fb57f122033a68aeb4ad3943132a677fb46..92fa3bb708ee2c965a76554268afee4db11f381d 100644
|
||||
index 7abd4f38ae59a6019137345af960fd60a3c7adf0..426777730f77664c69bd0a084a9323d767ebc0ad 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -1,24 +1,21 @@
|
||||
package net.minecraft.server.dedicated;
|
||||
|
||||
-import com.google.common.collect.Lists;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.logging.LogUtils;
|
||||
-import java.io.BufferedReader;
|
||||
+
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
-import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Proxy;
|
||||
-import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
-import java.util.Collections;
|
||||
-import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -58,7 +55,6 @@ import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.io.IoBuilder;
|
||||
import org.bukkit.command.CommandSender;
|
||||
-import co.aikar.timings.MinecraftTimings; // Paper
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
import org.bukkit.craftbukkit.util.Waitable;
|
||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
@@ -227,6 +223,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
}
|
||||
org.purpurmc.purpur.PurpurConfig.registerCommands();
|
||||
// Purpur end
|
||||
@@ -218,6 +218,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
thread.start(); // Paper - start console thread after MinecraftServer.console & PaperConfig are initialized
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this);
|
||||
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics();
|
||||
+ // Kaiiju start
|
||||
+ try {
|
||||
+ KaiijuConfig.init((java.io.File) options.valueOf("kaiiju-settings"));
|
||||
+ dev.kaiijumc.kaiiju.KaiijuConfig.init((java.io.File) options.valueOf("kaiiju-settings"));
|
||||
+ } catch (Exception e) {
|
||||
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
|
||||
+ return false;
|
||||
+ }
|
||||
+ KaiijuConfig.registerCommands();
|
||||
+ dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands();
|
||||
+ // Kaiiju end
|
||||
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now
|
||||
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
||||
// Paper end
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index a9289072b048095330ea32d7c965e8dda61a36fc..ce8873c47ec10d31d617a10128bed6ff21a24a39 100644
|
||||
index c7c682cd2d1498e6d6521ddd62acdc1168bfe152..53b9444ff6120628d23ad27fc87d9cd9bdf66648 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1,10 +1,7 @@
|
||||
package net.minecraft.world.level;
|
||||
|
||||
-import co.aikar.timings.Timing;
|
||||
-import co.aikar.timings.Timings;
|
||||
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
import com.destroystokyo.paper.exception.ServerInternalException;
|
||||
-import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import java.io.IOException;
|
||||
@@ -15,9 +12,10 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import dev.kaiijumc.kaiiju.KaiijuWorldConfig;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
-import net.minecraft.ReportedException;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
@@ -35,15 +33,12 @@ import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
-import net.minecraft.util.AbortableIterationConsumer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
-import net.minecraft.world.entity.boss.EnderDragonPart;
|
||||
-import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -89,17 +84,14 @@ import net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDelayPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDistancePacket;
|
||||
import org.bukkit.Bukkit;
|
||||
-import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CapturedBlockState;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.util.CraftSpawnCategory;
|
||||
-import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.SpawnCategory;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
-import org.bukkit.event.world.GenericGameEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -174,6 +166,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -167,6 +167,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
// Paper end
|
||||
|
||||
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
|
||||
public final org.purpurmc.purpur.PurpurWorldConfig purpurConfig; // Purpur
|
||||
+ public final KaiijuWorldConfig kaiijuConfig; // Kaiiju
|
||||
|
||||
+ public final dev.kaiijumc.kaiiju.KaiijuWorldConfig kaiijuConfig; // Kaiiju
|
||||
+
|
||||
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
|
||||
public static BlockPos lastPhysicsProblem; // Spigot
|
||||
@@ -330,6 +323,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
private org.spigotmc.TickLimiter entityLimiter;
|
||||
@@ -294,6 +296,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
|
||||
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
||||
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
|
||||
this.purpurConfig = new org.purpurmc.purpur.PurpurWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), env); // Purpur
|
||||
+ this.kaiijuConfig = new KaiijuWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), env); // Kaiiju
|
||||
this.playerBreedingCooldowns = this.getNewBreedingCooldownCache(); // Purpur
|
||||
+ this.kaiijuConfig = new dev.kaiijumc.kaiiju.KaiijuWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), env); // Kaiiju
|
||||
this.generator = gen;
|
||||
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index caf1237491649205f7b3c7ea4fe1d31d567bbafe..eacb6fbd753b8448bc8732eec2dc3444b6e93136 100644
|
||||
index b1680507c05547458e1199412ab97105b67f8973..d1468cb0ae1850719d40524dad9b14fbdb0f79a1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -7,7 +7,6 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
-import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@@ -16,6 +15,7 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -108,7 +108,6 @@ import net.minecraft.world.level.levelgen.PatrolSpawner;
|
||||
import net.minecraft.world.level.levelgen.PhantomSpawner;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||
-import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.saveddata.maps.MapDecoration;
|
||||
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
||||
@@ -1032,6 +1031,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1067,6 +1067,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
org.purpurmc.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur
|
||||
+ KaiijuConfig.init((File) console.options.valueOf("kaiiju-settings")); // Kaiiju
|
||||
+ dev.kaiijumc.kaiiju.KaiijuConfig.init((File) console.options.valueOf("kaiiju-settings")); // Kaiiju
|
||||
for (ServerLevel world : this.console.getAllLevels()) {
|
||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
@@ -1048,6 +1048,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1082,6 +1083,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
}
|
||||
world.spigotConfig.init(); // Spigot
|
||||
world.purpurConfig.init(); // Purpur
|
||||
+ world.kaiijuConfig.init(); // Kaiiju
|
||||
}
|
||||
|
||||
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
||||
@@ -1064,6 +1065,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1097,6 +1099,7 @@ public final class CraftServer implements Server {
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur
|
||||
+ KaiijuConfig.registerCommands(); // Kaiiju
|
||||
+ dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands(); // Kaiiju
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -2885,6 +2887,13 @@ public final class CraftServer implements Server {
|
||||
@@ -2857,6 +2860,13 @@ public final class CraftServer implements Server {
|
||||
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
||||
}
|
||||
// Purpur end
|
||||
|
||||
+ // Kaiiju start
|
||||
+ @Override
|
||||
+ public YamlConfiguration getKaiijuConfig() {
|
||||
+ return KaiijuConfig.config;
|
||||
+ return dev.kaiijumc.kaiiju.KaiijuConfig.config;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
@@ -611,12 +495,12 @@ index caf1237491649205f7b3c7ea4fe1d31d567bbafe..eacb6fbd753b8448bc8732eec2dc3444
|
||||
public void restart() {
|
||||
org.spigotmc.RestartCommand.restart();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 576cd8e20982bb20d10213b6c7a229428eec1c2f..190b4bc55d8b1e9983f7b77fd3545a59fa39e6f8 100644
|
||||
index 4966a1e3dd35357a8ea6a7d2944c84c9c3e9058e..79a004dda72365afddb80fcd730828e351d7cce1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -180,6 +180,14 @@ public class Main {
|
||||
.describedAs("Yml file");
|
||||
// Purpur end
|
||||
@@ -173,6 +173,14 @@ public class Main {
|
||||
.describedAs("Jar file");
|
||||
// Paper end
|
||||
|
||||
+ // Purpur Start
|
||||
+ acceptsAll(asList("kaiiju", "kaiiju-settings"), "File for kaiiju settings")
|
||||
|
||||
@@ -5,39 +5,66 @@ Subject: [PATCH] Kaiiju RegionFormat Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index da7e04a93664e20b9187292ddb7c1f935f5f2883..66bbab7ebe1738cd937963b35fad9cdda763fa88 100644
|
||||
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..b86c90cc3601e666998cfa12f44515f605bb53eb 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
+import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -190,4 +191,15 @@ public class KaiijuConfig {
|
||||
@@ -192,4 +192,10 @@ public class KaiijuConfig {
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
+
|
||||
+ public static List<String> regionFormatList = Arrays.asList("ANVIL");
|
||||
+ public static String regionFormatName = "ANVIL";
|
||||
+ public static boolean regionFormatDebug = false;
|
||||
+
|
||||
+ private static void regionFormatSettings() {
|
||||
+ regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..b194f4dbebcbbf5bb4e026a0169e2d24806b46ec 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -4,9 +4,11 @@ import org.apache.commons.lang.BooleanUtils;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
+import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
+import java.util.logging.Level;
|
||||
|
||||
import static dev.kaiijumc.kaiiju.KaiijuConfig.log;
|
||||
|
||||
@@ -122,4 +124,23 @@ public class KaiijuWorldConfig {
|
||||
final Map<String, Object> value = getMap("world-settings." + worldName + "." + path, null);
|
||||
return value.isEmpty() ? fallback : value;
|
||||
}
|
||||
+
|
||||
+ public List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
|
||||
+ public String regionFormatName = "ANVIL";
|
||||
+ public int regionFormatLinearCompressionLevel = 1;
|
||||
+
|
||||
+ private void regionFormatSettings() {
|
||||
+ regionFormatName = getString("region-format.format", regionFormatName).toUpperCase();
|
||||
+ if (!regionFormatList.contains(regionFormatName)) {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Unknown region format in fusion.yml: " + regionFormatName);
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Falling back to ANVIL region file format.");
|
||||
+ log(Level.SEVERE, "Unknown region format in kaiiju.yml: " + regionFormatName);
|
||||
+ log(Level.SEVERE, "Falling back to ANVIL region file format.");
|
||||
+ regionFormatName = "ANVIL";
|
||||
+ }
|
||||
+ regionFormatLinearCompressionLevel = getInt("region-format.linear.compression-level", regionFormatLinearCompressionLevel);
|
||||
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
|
||||
+ log(Level.SEVERE, "Linear region compression level should be between 1 and 22 in kaiiju.yml: " + regionFormatLinearCompressionLevel);
|
||||
+ log(Level.SEVERE, "Falling back to compression level 1.");
|
||||
+ regionFormatLinearCompressionLevel = 1;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 40b4bd2f1a61c2d9a59c9c09b72713401969460b..b9998c288c4e8b6a244722915e44250b6550fd7e 100644
|
||||
index 0696ad97437726fd6a13badfe7db0617dfbfb1ad..a7233bcc99e9bf148348ebb36bbb15b2eadb381f 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -855,7 +855,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -897,7 +897,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper start - rewrite chunk system
|
||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force, close);
|
||||
if (flush) {
|
||||
@@ -46,7 +73,7 @@ index 40b4bd2f1a61c2d9a59c9c09b72713401969460b..b9998c288c4e8b6a244722915e44250b
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
}
|
||||
@@ -879,7 +879,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -921,7 +921,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
//MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); // Paper - move up
|
||||
}
|
||||
|
||||
|
||||
@@ -4,19 +4,17 @@ Date: Fri, 10 Feb 2023 22:21:56 +0200
|
||||
Subject: [PATCH] Kaiiju RegionFormat Linear
|
||||
|
||||
Documentation: https://github.com/xymb-endcrystalme/LinearRegionFileFormatTools
|
||||
Copyright xymb@endcrystal.me
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index c6a4c48b14a8c927284720b79b93ee1aa9df7da6..2ea3d2f26d4547ea5094cc63d492ea1406ffbd44 100644
|
||||
index 6dd416f65755ca0542e6661b8716672264120d59..4686019a152114e63e997ee103fc8424b24b4581 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -13,6 +13,10 @@ dependencies {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
}
|
||||
// Pufferfish end
|
||||
// Folia end
|
||||
+ // Kaiiju start - Linear format
|
||||
+ implementation("com.github.luben:zstd-jni:1.5.2-5")
|
||||
+ implementation("com.github.luben:zstd-jni:1.5.4-1")
|
||||
+ implementation("org.lz4:lz4-java:1.8.0")
|
||||
+ // Kaiiju end
|
||||
// Paper start
|
||||
@@ -37,25 +35,12 @@ index f2c27e0ac65be4b75c1d86ef6fd45fdb538d96ac..00724993d0448454d14a47652b039b88
|
||||
|
||||
public static final class InProgressWrite {
|
||||
public long writeCounter;
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index 66bbab7ebe1738cd937963b35fad9cdda763fa88..16ebf32e0c62025958c95216531f72cc418e8d14 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -192,7 +192,7 @@ public class KaiijuConfig {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
- public static List<String> regionFormatList = Arrays.asList("ANVIL");
|
||||
+ public static List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
|
||||
public static String regionFormatName = "ANVIL";
|
||||
|
||||
private static void regionFormatSettings() {
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..70d53d80f474eb80acc93275ad6bf1da98ea8ae7
|
||||
index 0000000000000000000000000000000000000000..249303116d3cfadd078ebf0ae6e44bf99eed6a47
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
|
||||
@@ -0,0 +1,32 @@
|
||||
@@ -0,0 +1,31 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
@@ -69,64 +54,54 @@ index 0000000000000000000000000000000000000000..70d53d80f474eb80acc93275ad6bf1da
|
||||
+import java.util.concurrent.locks.ReentrantLock;
|
||||
+
|
||||
+public interface AbstractRegionFile {
|
||||
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
|
||||
+ void flush() throws IOException;
|
||||
+ void setStatus(int x, int z, ChunkStatus status);
|
||||
+ void clear(ChunkPos pos) throws IOException;
|
||||
+ boolean hasChunk(ChunkPos pos);
|
||||
+ void close() throws IOException;
|
||||
+ void setStatus(int x, int z, ChunkStatus status);
|
||||
+ void setOversized(int x, int z, boolean b) throws IOException;
|
||||
+
|
||||
+ boolean hasChunk(ChunkPos pos);
|
||||
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
|
||||
+ boolean isOversized(int x, int z);
|
||||
+ boolean recalculateHeader() throws IOException;
|
||||
+
|
||||
+ DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException;
|
||||
+ DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException;
|
||||
+ ChunkStatus getStatusIfCached(int x, int z);
|
||||
+
|
||||
+ Path getRegionFile();
|
||||
+ ReentrantLock getFileLock();
|
||||
+
|
||||
+ void setOversized(int x, int z, boolean b) throws IOException;
|
||||
+ CompoundTag getOversizedData(int x, int z) throws IOException;
|
||||
+ boolean isOversized(int x, int z);
|
||||
+ boolean recalculateHeader() throws IOException;
|
||||
+ ChunkStatus getStatusIfCached(int x, int z);
|
||||
+ ReentrantLock getFileLock();
|
||||
+ Path getRegionFile();
|
||||
+}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0b84b1aa4b822bdcb783285e8ea99a4f25dbbaa3
|
||||
index 0000000000000000000000000000000000000000..dcfbabf54b19a4c29d5c95830242c5c26bf2f4aa
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java
|
||||
@@ -0,0 +1,38 @@
|
||||
@@ -0,0 +1,29 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFile;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFileVersion;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.nio.file.Path;
|
||||
+
|
||||
+public class AbstractRegionFileFactory {
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(linearCompression, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ return getAbstractRegionFile(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ return getAbstractRegionFile(linearCompression, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(File file, File directory, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(file.toPath(), directory.toPath(), RegionFileVersion.VERSION_DEFLATE, dsync);
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(linearCompression, file, directory, outputChunkStreamVersion, dsync, false);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(File file, File directory, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ return getAbstractRegionFile(file.toPath(), directory.toPath(), RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(file, directory, outputChunkStreamVersion, dsync, false);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ return new LinearRegionFile(file, directory, outputChunkStreamVersion, dsync, canRecalcHeader);
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ if (file.toString().endsWith(".linear")) {
|
||||
+ return new LinearRegionFile(file, linearCompression);
|
||||
+ } else {
|
||||
+ return new RegionFile(file, directory, outputChunkStreamVersion, dsync, canRecalcHeader);
|
||||
+ }
|
||||
@@ -134,10 +109,10 @@ index 0000000000000000000000000000000000000000..0b84b1aa4b822bdcb783285e8ea99a4f
|
||||
+}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52573d1944
|
||||
index 0000000000000000000000000000000000000000..245e3b1801c5f92054d9c0d0d8fc2a8fcfd6a1d4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||
@@ -0,0 +1,338 @@
|
||||
@@ -0,0 +1,328 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+import com.github.luben.zstd.ZstdInputStream;
|
||||
@@ -146,11 +121,9 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+import net.jpountz.lz4.LZ4Compressor;
|
||||
+import net.jpountz.lz4.LZ4Factory;
|
||||
+import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
+import net.jpountz.xxhash.XXHashFactory;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFileVersion;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
@@ -160,20 +133,33 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+import java.nio.file.Path;
|
||||
+import java.nio.file.StandardCopyOption;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.concurrent.locks.ReentrantLock;
|
||||
+
|
||||
+public class LinearRegionFile extends Thread implements AbstractRegionFile {
|
||||
+ private static long SUPERBLOCK = -4323716122432332390L;
|
||||
+ private static byte VERSION = 1;
|
||||
+ private static int HEADER_SIZE = 32;
|
||||
+ private static int FOOTER_SIZE = 8;
|
||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+ private final byte[][] buffer = new byte[32*32][];
|
||||
+ private final int[] bufferUncompressedSize = new int[32*32];
|
||||
+
|
||||
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
|
||||
+ private boolean markedToSave = false;
|
||||
+
|
||||
+ private final byte[][] buffer = new byte[1024][];
|
||||
+ private final int[] bufferUncompressedSize = new int[1024];
|
||||
+
|
||||
+ private final Object markedToSaveLock = new Object();
|
||||
+ private final ChunkStatus[] statuses = new ChunkStatus[1024];
|
||||
+
|
||||
+ private final LZ4Compressor compressor;
|
||||
+ private final LZ4FastDecompressor decompressor;
|
||||
+
|
||||
+ private boolean markedToSave = false;
|
||||
+ private boolean close = false;
|
||||
+ public Path regionFile;
|
||||
+
|
||||
+ public final ReentrantLock fileLock = new ReentrantLock(true);
|
||||
+ final byte COMPRESSION_LEVEL = 1;
|
||||
+ public Path regionFile;
|
||||
+
|
||||
+ private final int compressionLevel;
|
||||
+
|
||||
+ public Path getRegionFile() {
|
||||
+ return this.regionFile;
|
||||
@@ -183,78 +169,63 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ return this.fileLock;
|
||||
+ }
|
||||
+
|
||||
+ public LinearRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
||||
+ this.regionFile = file;
|
||||
+ this.compressionLevel = compression;
|
||||
+
|
||||
+ this.compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||
+ this.decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||
+
|
||||
+ File regionFile = new File(this.regionFile.toString());
|
||||
+
|
||||
+ LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||
+
|
||||
+ for (int i = 0 ; i < 32 * 32 ; i++)
|
||||
+ this.bufferUncompressedSize[i] = 0;
|
||||
+ Arrays.fill(this.bufferUncompressedSize, 0);
|
||||
+
|
||||
+ if(regionFile.canRead()) {
|
||||
+ long fileLength = file.toFile().length();
|
||||
+ FileInputStream fileStream = new FileInputStream(regionFile);
|
||||
+ DataInputStream rawDataStream = new DataInputStream(fileStream);
|
||||
+
|
||||
+ long SUPERBLOCK = -4323716122432332390L;
|
||||
+ byte VERSION = 1;
|
||||
+ int HEADER_SIZE = 32;
|
||||
+ int FOOTER_SIZE = 8;
|
||||
+
|
||||
+ long superBlock = rawDataStream.readLong();
|
||||
+
|
||||
+ if (superBlock != SUPERBLOCK) {
|
||||
+ System.out.println(file.toString());
|
||||
+ System.out.println("SUPERBLOCK INVALID!");
|
||||
+ return;
|
||||
+ }
|
||||
+ if (superBlock != SUPERBLOCK)
|
||||
+ throw new RuntimeException("Superblock invalid: " + superBlock + " file " + file);
|
||||
+
|
||||
+ byte version = rawDataStream.readByte();
|
||||
+ if (version != VERSION)
|
||||
+ throw new RuntimeException("Version invalid: " + version + " file " + file);
|
||||
+
|
||||
+ if (version != VERSION) {
|
||||
+ System.out.println(file.toString());
|
||||
+ System.out.println("VERSION INVALID!");
|
||||
+ return;
|
||||
+ }
|
||||
+ // Skip newestTimestamp (Long) + Compression level (Byte) + Chunk count (Short): Unused.
|
||||
+ rawDataStream.skipBytes(11);
|
||||
+
|
||||
+ rawDataStream.readLong(); // newestTimestamp
|
||||
+ rawDataStream.readByte(); // Compression level
|
||||
+ rawDataStream.readShort(); // Chunk count
|
||||
+ int dataCount = rawDataStream.readInt();
|
||||
+ long fileLength = file.toFile().length();
|
||||
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE)
|
||||
+ throw new IOException("File length invalid " + this.regionFile + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||
+
|
||||
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE) {
|
||||
+ throw new IOException("File length invalid " + this.regionFile + " " + String.valueOf(fileLength) + " " + String.valueOf(HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||
+ }
|
||||
+ rawDataStream.skipBytes(8); // Skip data hash (Long): Unused.
|
||||
+
|
||||
+ rawDataStream.readLong(); // Data Hash
|
||||
+ byte[] rawCompressed = new byte[dataCount];
|
||||
+
|
||||
+ rawDataStream.readFully(rawCompressed, 0, dataCount);
|
||||
+
|
||||
+ superBlock = rawDataStream.readLong();
|
||||
+
|
||||
+ if (superBlock != SUPERBLOCK) {
|
||||
+ if (superBlock != SUPERBLOCK)
|
||||
+ throw new IOException("Footer superblock invalid " + this.regionFile);
|
||||
+ }
|
||||
+
|
||||
+ DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)));
|
||||
+
|
||||
+ int[] starts = new int[32 * 32];
|
||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
||||
+ int[] starts = new int[1024];
|
||||
+ for(int i = 0; i < 1024; i++) {
|
||||
+ starts[i] = dataStream.readInt();
|
||||
+ dataStream.readInt(); // Skip timestamps
|
||||
+ dataStream.skipBytes(4); // Skip timestamps (Int): Unimplemented TODO: Implement per-chunk timestamps
|
||||
+ }
|
||||
+
|
||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
||||
+ for(int i = 0; i < 1024; i++) {
|
||||
+ if(starts[i] > 0) {
|
||||
+ int size = starts[i];
|
||||
+ byte[] b = new byte[size];
|
||||
+ dataStream.readFully(b, 0, size);
|
||||
+
|
||||
+ int maxCompressedLength = compressor.maxCompressedLength(size);
|
||||
+ int maxCompressedLength = this.compressor.maxCompressedLength(size);
|
||||
+ byte[] compressed = new byte[maxCompressedLength];
|
||||
+ int compressedLength = compressor.compress(b, 0, size, compressed, 0, maxCompressedLength);
|
||||
+ int compressedLength = this.compressor.compress(b, 0, size, compressed, 0, maxCompressedLength);
|
||||
+ b = new byte[compressedLength];
|
||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||
+
|
||||
@@ -294,9 +265,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ }
|
||||
+ for(int i = 0 ; i < 100 ; i++) {
|
||||
+ Thread.sleep(100);
|
||||
+ if(close) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if(close) return;
|
||||
+ }
|
||||
+ }
|
||||
+ } catch(InterruptedException ignored) {}
|
||||
@@ -307,11 +276,8 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ }
|
||||
+
|
||||
+ public synchronized void flush() throws IOException {
|
||||
+ if(!isMarkedToSave())
|
||||
+ return;
|
||||
+ if(!isMarkedToSave()) return;
|
||||
+
|
||||
+ long SUPERBLOCK = -4323716122432332390L;
|
||||
+ byte VERSION = 1;
|
||||
+ long timestamp = System.currentTimeMillis() / 1000L;
|
||||
+ short chunkCount = 0;
|
||||
+
|
||||
@@ -319,7 +285,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ FileOutputStream fileStream = new FileOutputStream(tempFile);
|
||||
+
|
||||
+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream();
|
||||
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, COMPRESSION_LEVEL);
|
||||
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel);
|
||||
+ zstdStream.setChecksum(true);
|
||||
+ DataOutputStream zstdDataStream = new DataOutputStream(zstdStream);
|
||||
+ DataOutputStream dataStream = new DataOutputStream(fileStream);
|
||||
@@ -327,25 +293,23 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ dataStream.writeLong(SUPERBLOCK);
|
||||
+ dataStream.writeByte(VERSION);
|
||||
+ dataStream.writeLong(timestamp);
|
||||
+ dataStream.writeByte(COMPRESSION_LEVEL);
|
||||
+ dataStream.writeByte(this.compressionLevel);
|
||||
+
|
||||
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||
+
|
||||
+ ArrayList<byte[]> byteBuffers = new ArrayList<byte[]>();
|
||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
||||
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
|
||||
+ for(int i = 0; i < 1024; i++) {
|
||||
+ if(this.bufferUncompressedSize[i] != 0) {
|
||||
+ chunkCount += 1;
|
||||
+ byte[] content = new byte[bufferUncompressedSize[i]];
|
||||
+ decompressor.decompress(buffer[i], 0, content, 0, bufferUncompressedSize[i]);
|
||||
+ this.decompressor.decompress(buffer[i], 0, content, 0, bufferUncompressedSize[i]);
|
||||
+
|
||||
+ byteBuffers.add(content);
|
||||
+ } else byteBuffers.add(null);
|
||||
+ }
|
||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
||||
+ for(int i = 0; i < 1024; i++) {
|
||||
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]);
|
||||
+ zstdDataStream.writeInt(0);
|
||||
+ zstdDataStream.writeInt(0); // TODO: IMPLEMENT PER CHUNK TIMESTAMPS
|
||||
+ }
|
||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
||||
+ for(int i = 0; i < 1024; i++) {
|
||||
+ if(byteBuffers.get(i) != null)
|
||||
+ zstdDataStream.write(byteBuffers.get(i), 0, byteBuffers.get(i).length);
|
||||
+ }
|
||||
@@ -356,11 +320,14 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ byte[] compressed = zstdByteArray.toByteArray();
|
||||
+
|
||||
+ dataStream.writeInt(compressed.length);
|
||||
+ dataStream.writeLong(XXHashFactory.fastestInstance().hash64().hash(compressed, 0, compressed.length, 0)); // TODO: Hash the contents, not the whole thing
|
||||
+ dataStream.writeLong(0);
|
||||
+
|
||||
+ dataStream.write(compressed, 0, compressed.length);
|
||||
+ dataStream.writeLong(SUPERBLOCK);
|
||||
+
|
||||
+ dataStream.flush();
|
||||
+ fileStream.getFD().sync();
|
||||
+ fileStream.getChannel().force(true); // Ensure atomicity on Btrfs
|
||||
+ dataStream.close();
|
||||
+
|
||||
+ fileStream.close();
|
||||
@@ -372,27 +339,26 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ }
|
||||
+
|
||||
+ public synchronized void write(ChunkPos pos, ByteBuffer buffer) {
|
||||
+ LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||
+ try {
|
||||
+ byte[] b = toByteArray(new ByteArrayInputStream(buffer.array()));
|
||||
+ int uncompressedSize = b.length;
|
||||
+
|
||||
+ int maxCompressedLength = compressor.maxCompressedLength(b.length);
|
||||
+ int maxCompressedLength = this.compressor.maxCompressedLength(b.length);
|
||||
+ byte[] compressed = new byte[maxCompressedLength];
|
||||
+ int compressedLength = compressor.compress(b, 0, b.length, compressed, 0, maxCompressedLength);
|
||||
+ int compressedLength = this.compressor.compress(b, 0, b.length, compressed, 0, maxCompressedLength);
|
||||
+ b = new byte[compressedLength];
|
||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||
+
|
||||
+ this.buffer[getChunkIndex(pos.x, pos.z)] = b;
|
||||
+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize;
|
||||
+ } catch (IOException e) {
|
||||
+ LOGGER.error("Chunk write IOException " + e.toString() + " " + this.regionFile);
|
||||
+ LOGGER.error("Chunk write IOException " + e + " " + this.regionFile);
|
||||
+ }
|
||||
+
|
||||
+ markToSave();
|
||||
+ }
|
||||
+
|
||||
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException {
|
||||
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) {
|
||||
+ return new DataOutputStream(new BufferedOutputStream(new LinearRegionFile.ChunkBuffer(pos)));
|
||||
+ }
|
||||
+
|
||||
@@ -424,11 +390,10 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException {
|
||||
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
|
||||
+ if(this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
|
||||
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||
+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]];
|
||||
+ decompressor.decompress(this.buffer[getChunkIndex(pos.x, pos.z)], 0, content, 0, bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]);
|
||||
+ this.decompressor.decompress(this.buffer[getChunkIndex(pos.x, pos.z)], 0, content, 0, bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]);
|
||||
+ return new DataInputStream(new ByteArrayInputStream(content));
|
||||
+ }
|
||||
+ return null;
|
||||
@@ -454,15 +419,15 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ try {
|
||||
+ flush();
|
||||
+ } catch(IOException e) {
|
||||
+ throw new IOException("Region flush IOException " + e.toString() + " " + this.regionFile);
|
||||
+ throw new IOException("Region flush IOException " + e + " " + this.regionFile);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static int getChunkIndex(int x, int z) {
|
||||
+ return (x & 31) + (z & 31) * 32;
|
||||
+ return (x & 31) + ((z & 31) << 5);
|
||||
+ }
|
||||
+
|
||||
+ public boolean recalculateHeader() throws IOException {
|
||||
+ public boolean recalculateHeader() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
@@ -477,7 +442,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a7bf09d2a 100644
|
||||
index 8a11e10b01fa012b2f98b1c193c53251e848f909..61001e76b38f8647b33e73b5cc15b4b6785cf49a 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
@@ -811,7 +811,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -489,17 +454,17 @@ index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a
|
||||
if (file == null) { // null if no regionfile exists
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
@@ -819,7 +819,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return file.hasChunk(chunkPos) ? Boolean.TRUE : Boolean.FALSE;
|
||||
});
|
||||
} else {
|
||||
@@ -824,7 +824,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return Boolean.FALSE;
|
||||
} // else: it either exists or is not known, fall back to checking the loaded region file
|
||||
|
||||
- return taskController.computeForRegionFileIfLoaded(chunkX, chunkZ, (final RegionFile file) -> {
|
||||
+ return taskController.computeForRegionFileIfLoaded(chunkX, chunkZ, (final dev.kaiijumc.kaiiju.region.AbstractRegionFile file) -> { // Kaiiju
|
||||
if (file == null) { // null if not loaded
|
||||
// not sure at this point, let the I/O thread figure it out
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
@@ -1116,9 +1116,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return !this.tasks.isEmpty();
|
||||
@@ -1126,9 +1126,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return this.getCache().doesRegionFileNotExistNoIO(new ChunkPos(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
- public <T> T computeForRegionFile(final int chunkX, final int chunkZ, final boolean existingOnly, final Function<RegionFile, T> function) {
|
||||
@@ -510,7 +475,7 @@ index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a
|
||||
synchronized (cache) {
|
||||
try {
|
||||
regionFile = cache.getRegionFile(new ChunkPos(chunkX, chunkZ), existingOnly, true);
|
||||
@@ -1131,19 +1131,19 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -1141,19 +1141,19 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return function.apply(regionFile);
|
||||
} finally {
|
||||
if (regionFile != null) {
|
||||
@@ -534,7 +499,7 @@ index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1151,7 +1151,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -1161,7 +1161,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return function.apply(regionFile);
|
||||
} finally {
|
||||
if (regionFile != null) {
|
||||
@@ -543,32 +508,49 @@ index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1287,6 +1287,12 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
} catch (final ThreadDeath thr) {
|
||||
throw thr;
|
||||
} catch (final Throwable thr) {
|
||||
+ // Kaiiju start - Linear region format
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ failedWrite = thr instanceof IOException;
|
||||
+ LOGGER.error("Failed to write chunk data for task: " + this.toString(), thr);
|
||||
+ } else {
|
||||
+ // Kaiiju end
|
||||
if (thr instanceof RegionFileStorage.RegionFileSizeException) {
|
||||
final int maxSize = RegionFile.MAX_CHUNK_SIZE / (1024 * 1024);
|
||||
LOGGER.error("Chunk at (" + this.chunkX + "," + this.chunkZ + ") in '" + this.world.getWorld().getName() + "' exceeds max size of " + maxSize + "MiB, it has been deleted from disk.");
|
||||
@@ -1294,6 +1300,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
failedWrite = thr instanceof IOException;
|
||||
LOGGER.error("Failed to write chunk data for task: " + this.toString(), thr);
|
||||
}
|
||||
+ } // Kaiiju
|
||||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
index 513833c2ea23df5b079d157bc5cb89d5c9754c0b..a62a1b281bd0b6ad7d59b45b9470d84f496f6539 100644
|
||||
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
@@ -83,9 +83,13 @@ public class ThreadedWorldUpgrader {
|
||||
}
|
||||
LOGGER.info("Found " + regionFiles.length + " regionfiles to convert");
|
||||
LOGGER.info("Starting conversion now for world " + this.worldName);
|
||||
-
|
||||
+ // Kaiiju start
|
||||
+ String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
||||
+ int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||
+ LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
|
||||
+ // Kaiiju end
|
||||
final WorldInfo info = new WorldInfo(() -> worldPersistentData,
|
||||
- new ChunkStorage(regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey);
|
||||
+ new ChunkStorage(formatName, linearCompression, regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey); // Kaiiju
|
||||
|
||||
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
||||
|
||||
final boolean finalFailWrite = failedWrite;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..2158c576aa47ef618b7602c2f4e351b7beb023b3 100644
|
||||
index c8bc7db4c22f48047aa409f0bcff3ef8c4034781..5ad209fed6aef1992af0472ac0af0911d178a260 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -950,13 +950,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -272,7 +272,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper end
|
||||
|
||||
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
||||
- super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
|
||||
+ super(world.getLevel().kaiijuConfig.regionFormatName, world.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
|
||||
// Paper - rewrite chunk system
|
||||
this.tickingGenerated = new AtomicInteger();
|
||||
//this.playerMap = new PlayerMap(); // Folia - region threading
|
||||
@@ -317,7 +317,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.lightEngine = new ThreadedLevelLightEngine(chunkProvider, this, this.level.dimensionType().hasSkyLight(), null, null); // Paper - rewrite chunk system
|
||||
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
||||
this.overworldDataStorage = persistentStateManagerFactory;
|
||||
- this.poiManager = new PoiManager(path.resolve("poi"), dataFixer, dsync, iregistrycustom, world);
|
||||
+ this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||
this.setViewDistance(viewDistance);
|
||||
// Paper start
|
||||
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
||||
@@ -853,13 +853,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
// Paper start - chunk status cache "api"
|
||||
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
||||
@@ -584,7 +566,7 @@ index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..2158c576aa47ef618b7602c2f4e351b7
|
||||
|
||||
if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
|
||||
return null;
|
||||
@@ -974,7 +974,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -877,7 +877,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException {
|
||||
@@ -593,50 +575,115 @@ index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..2158c576aa47ef618b7602c2f4e351b7
|
||||
|
||||
regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkSerializer.getStatus(compound));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index acc8af33ad8534d812908b0feb9a1963ee2c64fb..20359c63b19c7e0c703ef1562fb774803d631c41 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -425,9 +425,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
private final EntityRegionFileStorage entityStorage;
|
||||
|
||||
private static final class EntityRegionFileStorage extends net.minecraft.world.level.chunk.storage.RegionFileStorage {
|
||||
-
|
||||
- public EntityRegionFileStorage(Path directory, boolean dsync) {
|
||||
- super(directory, dsync);
|
||||
+ public EntityRegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
||||
+ super(format, linearCompression, directory, dsync); // Kaiiju
|
||||
}
|
||||
|
||||
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
|
||||
@@ -633,7 +632,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// CraftBukkit end
|
||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||
- this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
|
||||
+ this.entityStorage = new EntityRegionFileStorage(this.getLevel().kaiijuConfig.regionFormatName, this.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); // Kaiiju
|
||||
|
||||
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
|
||||
StructureTemplateManager structuretemplatemanager = minecraftserver.getStructureManager();
|
||||
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
index 759b125cc1251b9b4f1f443c9f70c482ef5b32f8..aca60733c87f7f95b5719ded24eb8cf697f9d83e 100644
|
||||
index e0bfeebeaac1aaea64bc07cdfdf7790e3e43ca7b..469802b9c454c5e98c0a55ba89559d9d8ba0c4c0 100644
|
||||
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
@@ -61,10 +61,17 @@ public class WorldUpgrader {
|
||||
@@ -61,7 +61,7 @@ public class WorldUpgrader {
|
||||
private volatile int skipped;
|
||||
private final Object2FloatMap<ResourceKey<LevelStem>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy())); // CraftBukkit
|
||||
private volatile Component status = Component.translatable("optimizeWorld.stage.counting");
|
||||
- public static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||
+ public static Pattern REGEX; // Kaiiju
|
||||
+ public static Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // Kaiiju
|
||||
private final DimensionDataStorage overworldDataStorage;
|
||||
|
||||
public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, Registry<LevelStem> dimensionOptionsRegistry, boolean eraseCache) {
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ this.REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.linear$");
|
||||
+ } else {
|
||||
+ this.REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
this.dimensions = dimensionOptionsRegistry;
|
||||
this.levels = (Set) dimensionOptionsRegistry.registryKeySet().stream().collect(Collectors.toUnmodifiableSet()); // CraftBukkit
|
||||
this.eraseCache = eraseCache;
|
||||
@@ -235,6 +242,11 @@ public class WorldUpgrader {
|
||||
@@ -115,8 +115,12 @@ public class WorldUpgrader {
|
||||
while (iterator1.hasNext()) {
|
||||
ResourceKey<LevelStem> resourcekey1 = (ResourceKey) iterator1.next(); // CraftBukkit
|
||||
Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit
|
||||
-
|
||||
- builder1.put(resourcekey1, new ChunkStorage(path.resolve("region"), this.dataFixer, true));
|
||||
+ // Kaiiju start
|
||||
+ String worldName = this.levelStorage.getLevelId();
|
||||
+ String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
||||
+ int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||
+ builder1.put(resourcekey1, new ChunkStorage(formatName, linearCompression, path.resolve("region"), this.dataFixer, true));
|
||||
+ // Kaiiju end
|
||||
}
|
||||
|
||||
ImmutableMap<ResourceKey<LevelStem>, ChunkStorage> immutablemap1 = builder1.build(); // CraftBukkit
|
||||
@@ -235,7 +239,7 @@ public class WorldUpgrader {
|
||||
File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit
|
||||
File file1 = new File(file, "region");
|
||||
File[] afile = file1.listFiles((file2, s) -> {
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ return s.endsWith(".linear");
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return s.endsWith(".mca");
|
||||
- return s.endsWith(".mca");
|
||||
+ return s.endsWith(".mca") || s.endsWith(".linear"); // Kaiiju
|
||||
});
|
||||
|
||||
@@ -254,7 +266,7 @@ public class WorldUpgrader {
|
||||
if (afile == null) {
|
||||
@@ -254,7 +258,11 @@ public class WorldUpgrader {
|
||||
int l = Integer.parseInt(matcher.group(2)) << 5;
|
||||
|
||||
try {
|
||||
- RegionFile regionfile = new RegionFile(file2.toPath(), file1.toPath(), true);
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(file2.toPath(), file1.toPath(), true); // Kaiiju
|
||||
+ // Kaiiju start
|
||||
+ String worldName = this.levelStorage.getLevelId();
|
||||
+ int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(linearCompression, file2.toPath(), file1.toPath(), true);
|
||||
+ // Kaiiju end
|
||||
|
||||
try {
|
||||
for (int i1 = 0; i1 < 32; ++i1) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
index 9c56304476b4fc841b5d7694232617586ebd8e84..f560aa13c6c8ffecb456f478687dc6a9eb5e8017 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
@@ -59,8 +59,8 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
||||
// Paper end - rewrite chunk system
|
||||
|
||||
|
||||
- public PoiManager(Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) {
|
||||
- super(path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world);
|
||||
+ public PoiManager(String formatName, int linearCompression, Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) { // Kaiiju
|
||||
+ super(formatName, linearCompression, path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world); // Kaiiju
|
||||
this.world = (net.minecraft.server.level.ServerLevel)world; // Paper - rewrite chunk system
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
index 29facbdcbad17ce38bf785f7f3f8346d81cbc32f..52c2e0fe73a5af18535a2b0b9a506919e3f93003 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
@@ -37,11 +37,12 @@ public class ChunkStorage implements AutoCloseable {
|
||||
public final RegionFileStorage regionFileCache;
|
||||
// Paper end - async chunk loading
|
||||
|
||||
- public ChunkStorage(Path directory, DataFixer dataFixer, boolean dsync) {
|
||||
+ public ChunkStorage(String format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
||||
this.fixerUpper = dataFixer;
|
||||
+
|
||||
// Paper start - async chunk io
|
||||
// remove IO worker
|
||||
- this.regionFileCache = new RegionFileStorage(directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
+ this.regionFileCache = new RegionFileStorage(format, linearCompression, directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
// Paper end - async chunk io
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788ecafb8e9d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -699,39 +746,53 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788e
|
||||
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
|
||||
return NbtIo.read((java.io.DataInput) out);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da747cf30c 100644
|
||||
index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d01a6381c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -21,8 +21,9 @@ import net.minecraft.world.level.ChunkPos;
|
||||
public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -22,9 +22,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
public static final String ANVIL_EXTENSION = ".mca";
|
||||
+ public static final String LINEAR_EXTENSION = ".linear"; // Kaiiju
|
||||
private static final int MAX_CACHE_SIZE = 256;
|
||||
- public final Long2ObjectLinkedOpenHashMap<RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap();
|
||||
+ public final Long2ObjectLinkedOpenHashMap<dev.kaiijumc.kaiiju.region.AbstractRegionFile> regionCache = new Long2ObjectLinkedOpenHashMap(); // Kaiiju
|
||||
private final Path folder;
|
||||
private final boolean sync;
|
||||
+ // Kaiiju start - Per world chunk format
|
||||
+ public final String format;
|
||||
+ public final int linearCompression;
|
||||
+ // Kaiiju end
|
||||
|
||||
@@ -42,9 +43,17 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
private final boolean isChunkData; // Paper
|
||||
|
||||
@@ -57,11 +61,15 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
// Paper end - cache regionfile does not exist state
|
||||
|
||||
- protected RegionFileStorage(Path directory, boolean dsync) { // Paper - protected constructor
|
||||
+ protected RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Paper - protected constructor
|
||||
// Paper start - add isChunkData param
|
||||
- this(directory, dsync, false);
|
||||
+ this(format, linearCompression, directory, dsync, false);
|
||||
}
|
||||
- RegionFileStorage(Path directory, boolean dsync, boolean isChunkData) {
|
||||
+ RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
||||
+ // Kaiiju start
|
||||
+ this.format = format;
|
||||
+ this.linearCompression = linearCompression;
|
||||
+ // Kaiiju end
|
||||
this.isChunkData = isChunkData;
|
||||
// Paper end - add isChunkData param
|
||||
this.folder = directory;
|
||||
@@ -71,7 +79,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
// Paper start
|
||||
public static @Nullable ChunkPos getRegionFileCoordinates(Path file) {
|
||||
String fileName = file.getFileName().toString();
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".linear")) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ } else {
|
||||
+ // Kaiiju end
|
||||
if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
|
||||
- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
|
||||
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".mca") || !fileName.endsWith(".linear")) { // Kaiiju
|
||||
return null;
|
||||
}
|
||||
+ } // Kaiiju
|
||||
|
||||
String[] split = fileName.split("\\.");
|
||||
|
||||
@@ -62,49 +71,57 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -91,29 +99,29 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,7 +815,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
- public synchronized RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly, boolean lock) throws IOException {
|
||||
+ public synchronized dev.kaiijumc.kaiiju.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly, boolean lock) throws IOException { // Kaiiju
|
||||
// Paper end
|
||||
long i = ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
|
||||
long i = ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()); final long regionPos = i; // Paper - OBFHELPER
|
||||
- RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i);
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile = this.regionCache.getAndMoveToFirst(i); // Kaiiju
|
||||
|
||||
@@ -767,28 +828,50 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
}
|
||||
// Paper end
|
||||
return regionfile;
|
||||
} else {
|
||||
@@ -124,28 +132,46 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
// Paper end - cache regionfile does not exist state
|
||||
if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - configurable
|
||||
- ((RegionFile) this.regionCache.removeLast()).close();
|
||||
+ this.regionCache.removeLast().close(); // Kaiiju
|
||||
}
|
||||
|
||||
FileUtil.createDirectoriesSafe(this.folder);
|
||||
// Paper - only create directory if not existing only - moved down
|
||||
Path path = this.folder;
|
||||
int j = chunkcoordintpair.getRegionX();
|
||||
- Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change
|
||||
+ // Kaiiju start
|
||||
- if (existingOnly && !java.nio.file.Files.exists(path1)) { // Paper start - cache regionfile does not exist state
|
||||
- this.markNonExisting(regionPos);
|
||||
- return null; // CraftBukkit
|
||||
+ // Kaiiju start - Polyglot
|
||||
+ //Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change
|
||||
+ Path path1;
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
|
||||
+ } else {
|
||||
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
|
||||
+ if (existingOnly) {
|
||||
+ Path anvil = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||
+ Path linear = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
|
||||
+ if (java.nio.file.Files.exists(anvil)) path1 = anvil;
|
||||
+ else if (java.nio.file.Files.exists(linear)) path1 = linear;
|
||||
+ else {
|
||||
+ this.markNonExisting(regionPos);
|
||||
+ return null;
|
||||
+ }
|
||||
} else {
|
||||
+ String extension = switch (this.format) {
|
||||
+ case "LINEAR" -> "linear";
|
||||
+ default -> "mca";
|
||||
+ };
|
||||
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension);
|
||||
this.createRegionFile(regionPos);
|
||||
}
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatDebug)
|
||||
+ org.bukkit.Bukkit.getLogger().info("Opening file " + path1 + " with format " + this.format + " (existingOnly = " + existingOnly + ")");
|
||||
+
|
||||
// Paper end - cache regionfile does not exist state
|
||||
FileUtil.createDirectoriesSafe(this.folder); // Paper - only create directory if not existing only - moved from above
|
||||
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile1 = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Kaiiju
|
||||
+ // Kaiiju end
|
||||
+
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile1 = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(this.linearCompression, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Kaiiju
|
||||
|
||||
this.regionCache.putAndMoveToFirst(i, regionfile1);
|
||||
// Paper start
|
||||
@@ -799,7 +882,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
}
|
||||
// Paper end
|
||||
return regionfile1;
|
||||
@@ -132,7 +149,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -173,7 +199,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
|
||||
|
||||
@@ -808,7 +891,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
synchronized (regionfile) {
|
||||
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
|
||||
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
|
||||
@@ -179,14 +196,14 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -220,14 +246,14 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@Nullable
|
||||
public CompoundTag read(ChunkPos pos) throws IOException {
|
||||
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
@@ -825,7 +908,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
// We add the regionfile parameter to avoid the potential deadlock (on fileLock) if we went back to obtain a regionfile
|
||||
// if we decide to re-read
|
||||
// Paper end
|
||||
@@ -196,7 +213,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -237,7 +263,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
// Paper start
|
||||
if (regionfile.isOversized(pos.x, pos.z)) {
|
||||
@@ -834,7 +917,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
return readOversizedChunk(regionfile, pos);
|
||||
}
|
||||
// Paper end
|
||||
@@ -210,12 +227,12 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -251,12 +277,12 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
if (this.isChunkData) {
|
||||
ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound);
|
||||
if (!chunkPos.equals(pos)) {
|
||||
@@ -850,7 +933,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -249,13 +266,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -290,13 +316,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
return nbttagcompound;
|
||||
} finally { // Paper start
|
||||
@@ -866,7 +949,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
if (regionfile == null) {
|
||||
return;
|
||||
}
|
||||
@@ -285,7 +302,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -326,7 +352,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
|
||||
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
|
||||
@@ -875,7 +958,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
if (nbt == null && regionfile == null) {
|
||||
return;
|
||||
}
|
||||
@@ -335,7 +352,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -376,7 +402,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
// Paper end
|
||||
} finally { // Paper start
|
||||
@@ -884,7 +967,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
} // Paper end
|
||||
}
|
||||
|
||||
@@ -344,7 +361,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -385,7 +411,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -893,7 +976,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
|
||||
try {
|
||||
regionfile.close();
|
||||
@@ -360,7 +377,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -401,7 +427,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -902,11 +985,26 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
|
||||
regionfile.flush();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
index 5561b8499a0503b850974b1dc309edfb80219549..414aa3ae00c2d28e754235e3e93b6b623d4fd180 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
@@ -47,8 +47,8 @@ public class SectionStorage<R> extends RegionFileStorage implements AutoCloseabl
|
||||
public final RegistryAccess registryAccess; // Paper - rewrite chunk system
|
||||
protected final LevelHeightAccessor levelHeightAccessor;
|
||||
|
||||
- public SectionStorage(Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) {
|
||||
- super(path, dsync); // Paper - remove mojang I/O thread
|
||||
+ public SectionStorage(String format, int linearCompression, Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) { // Kaiiju
|
||||
+ super(format, linearCompression, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
|
||||
this.codec = codecFactory;
|
||||
this.factory = factory;
|
||||
this.fixerUpper = dataFixer;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index b17bc6482d2bd97d2e48d3967dea72605cf13164..2a13629ffb60dc60706da446e6dc7f3683d0410b 100644
|
||||
index 2ead9af36c4d41c61b68a960ff17e25894efeb2a..cba3411386b7a9f596017d021d08f30c78f0c52b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -552,7 +552,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@@ -554,7 +554,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Sat, 11 Feb 2023 02:10:20 +0200
|
||||
Subject: [PATCH] Kaiiju Lobotomize Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..ac4440f8d2bd30e3e074ef797d5138b64996fcbb 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -122,4 +122,7 @@ public class KaiijuWorldConfig {
|
||||
final Map<String, Object> value = getMap("world-settings." + worldName + "." + path, null);
|
||||
return value.isEmpty() ? fallback : value;
|
||||
}
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+
|
||||
+ private void lobotomizeSettings() {
|
||||
+ }
|
||||
+}
|
||||
18
patches/server/0005-Kaiiju-Network-Configuration.patch
Normal file
18
patches/server/0005-Kaiiju-Network-Configuration.patch
Normal file
@@ -0,0 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Thu, 16 Feb 2023 01:38:59 +0200
|
||||
Subject: [PATCH] Kaiiju Network Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index b86c90cc3601e666998cfa12f44515f605bb53eb..7c6d43d8a360530344ef296f4477750c8a298607 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -198,4 +198,7 @@ public class KaiijuConfig {
|
||||
private static void regionFormatSettings() {
|
||||
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
||||
}
|
||||
+
|
||||
+ private static void networkSettings() {
|
||||
+ }
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Sat, 11 Feb 2023 06:29:15 +0200
|
||||
Subject: [PATCH] Kaiiju Lobotomize Animal
|
||||
|
||||
Inspired by "Lobotomized animals" by @KioProject123
|
||||
Checks might be a nuisance to performance.
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index ac4440f8d2bd30e3e074ef797d5138b64996fcbb..dbbba258dbdc465b89c71508d76c5c596fd03bea 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -123,6 +123,15 @@ public class KaiijuWorldConfig {
|
||||
return value.isEmpty() ? fallback : value;
|
||||
}
|
||||
|
||||
+ public boolean lobotomizeAnimalEnabled = false;
|
||||
+ public int lobotomizeAnimalCheckInterval = 100;
|
||||
+ public boolean lobotomizeAnimalLookAtPlayer = false;
|
||||
+ public boolean lobotomizeAnimalFloat = true;
|
||||
+
|
||||
private void lobotomizeSettings() {
|
||||
+ lobotomizeAnimalEnabled = getBoolean("lobotomize.animal.enabled", lobotomizeAnimalEnabled);
|
||||
+ lobotomizeAnimalCheckInterval = getInt("lobotomize.animal.check-interval", lobotomizeAnimalCheckInterval);
|
||||
+ lobotomizeAnimalLookAtPlayer = getBoolean("lobotomize.animal.look-at-player", lobotomizeAnimalLookAtPlayer);
|
||||
+ lobotomizeAnimalFloat = getBoolean("lobotomize.animal.float", lobotomizeAnimalFloat);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/entity/Lobotomized.java b/src/main/java/dev/kaiijumc/kaiiju/entity/Lobotomized.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8912f25e94d5e7510d965aa02b73c87e0b75fb51
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/entity/Lobotomized.java
|
||||
@@ -0,0 +1,56 @@
|
||||
+package dev.kaiijumc.kaiiju.entity;
|
||||
+
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.world.entity.LivingEntity;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.block.state.BlockState;
|
||||
+import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
+
|
||||
+public class Lobotomized {
|
||||
+ private boolean isLobotomized = false;
|
||||
+ private int notLobotomizedCount = 0;
|
||||
+
|
||||
+ public boolean isLobotomized() {
|
||||
+ return this.isLobotomized;
|
||||
+ }
|
||||
+
|
||||
+ public void setLobotomized(boolean b) {
|
||||
+ this.isLobotomized = b;
|
||||
+ }
|
||||
+
|
||||
+ public boolean checkLobotomized(LivingEntity livingEntity) {
|
||||
+ Level level = livingEntity.getLevel();
|
||||
+ int interval = level.kaiijuConfig.lobotomizeAnimalCheckInterval;
|
||||
+ if (this.notLobotomizedCount > 3) {
|
||||
+ // check half as often if not lobotomized for the last 3+ consecutive checks
|
||||
+ interval *= 2;
|
||||
+ }
|
||||
+ if ((livingEntity.getId() + livingEntity.tickCount) % interval == 0) {
|
||||
+ this.isLobotomized = livingEntity.isOnGround() && !canTravelFrom(new BlockPos(livingEntity.getX(), livingEntity.getY() + 0.5D, livingEntity.getZ()), level, livingEntity.getBbHeight() <= 1.0F);
|
||||
+
|
||||
+ if (this.isLobotomized) {
|
||||
+ this.notLobotomizedCount = 0;
|
||||
+ } else {
|
||||
+ this.notLobotomizedCount++;
|
||||
+ }
|
||||
+ }
|
||||
+ return this.isLobotomized;
|
||||
+ }
|
||||
+
|
||||
+ private boolean canTravelFrom(BlockPos pos, Level level, boolean ignoreTop) {
|
||||
+ return canTravelTo(pos.east(), level, ignoreTop)
|
||||
+ || canTravelTo(pos.west(), level, ignoreTop)
|
||||
+ || canTravelTo(pos.north(), level, ignoreTop)
|
||||
+ || canTravelTo(pos.south(), level, ignoreTop);
|
||||
+ }
|
||||
+
|
||||
+ private boolean canTravelTo(BlockPos pos, Level level, boolean ignoreTop) {
|
||||
+ BlockState bottom = level.getBlockStateIfLoaded(pos);
|
||||
+ if (bottom == null) return false; // Chunk not loaded
|
||||
+ if (!bottom.isPathfindable(level, pos, PathComputationType.LAND)) return false;
|
||||
+ if (ignoreTop) return true;
|
||||
+ BlockState top = level.getBlockState(pos.above());
|
||||
+ if (!top.isPathfindable(level, pos, PathComputationType.LAND)) return false;
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index b2e4b5c463ceb19356da18e7fc52d20801b674cd..32ea0b1542ef374db3290e01978d7965715b9de6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -308,6 +308,8 @@ public abstract class LivingEntity extends Entity {
|
||||
this.brain = this.makeBrain(new Dynamic(dynamicopsnbt, (Tag) dynamicopsnbt.createMap((Map) ImmutableMap.of(dynamicopsnbt.createString("memories"), (Tag) dynamicopsnbt.emptyMap()))));
|
||||
}
|
||||
|
||||
+ public boolean isLobotomized() { return false; } // Kaiiju
|
||||
+
|
||||
protected void initAttributes() {}// Purpur
|
||||
|
||||
public Brain<?> getBrain() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/FloatGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/FloatGoal.java
|
||||
index 7093c62be53fe99ed9880fc8ddaa07440fe4f715..2acbb26af2c24b2f4c569d55e8ba44a068fd9d86 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/FloatGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/FloatGoal.java
|
||||
@@ -16,6 +16,7 @@ public class FloatGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
+ if (!this.mob.getLevel().kaiijuConfig.lobotomizeAnimalFloat && this.mob.isLobotomized()) return false; // Kaiiju
|
||||
return this.mob.isInWater() && this.mob.getFluidHeight(FluidTags.WATER) > this.mob.getFluidJumpThreshold() || this.mob.isInLava();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/FollowParentGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/FollowParentGoal.java
|
||||
index a668d5263586f955a5656ac66bcc7fe8cc51fe00..c195e60a7773f106775cded4f1c3ed51a69ca2f5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/FollowParentGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/FollowParentGoal.java
|
||||
@@ -21,6 +21,7 @@ public class FollowParentGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
+ if (this.animal.isLobotomized()) return false; // Kaiiju
|
||||
if (this.animal.getAge() >= 0) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -51,6 +52,7 @@ public class FollowParentGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
+ if (this.animal.isLobotomized()) return false; // Kaiiju
|
||||
if (this.animal.getAge() >= 0) {
|
||||
return false;
|
||||
} else if (!this.parent.isAlive()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/LookAtPlayerGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/LookAtPlayerGoal.java
|
||||
index 8b189d7587303263efa1790066e5a83edd45f9d7..1304fc96834e4ce7156076fd893993a0aa75cbbc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/LookAtPlayerGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/LookAtPlayerGoal.java
|
||||
@@ -48,6 +48,7 @@ public class LookAtPlayerGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
+ if (!mob.getLevel().kaiijuConfig.lobotomizeAnimalLookAtPlayer && this.mob.isLobotomized()) return false; // Kaiiju
|
||||
if (this.mob.getRandom().nextFloat() >= this.probability) {
|
||||
return false;
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/PanicGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/PanicGoal.java
|
||||
index 268b7457c2a93af6d36c1c5f623c5856f94a7af1..f1469e424f7bdf4e5813f250c0eae673db0b9049 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/PanicGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/PanicGoal.java
|
||||
@@ -29,6 +29,7 @@ public class PanicGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
+ if (this.mob.isLobotomized()) return false; // Kaiiju
|
||||
if (!this.shouldPanic()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -81,6 +82,7 @@ public class PanicGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
+ if (this.mob.isLobotomized()) return false; // Kaiiju
|
||||
// CraftBukkit start - introduce a temporary timeout hack until this is fixed properly
|
||||
if ((this.mob.tickCount - this.mob.lastHurtByMobTimestamp) > 100) {
|
||||
this.mob.setLastHurtByMob((LivingEntity) null);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java
|
||||
index 216929c838446c3c14d9b9906ffa625ef35fcbc8..3ea2e7c44018ec63b8f17fd3e5e3a23e2b1f72e4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java
|
||||
@@ -35,6 +35,7 @@ public class RandomStrollGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
+ if (this.mob.isLobotomized()) return false; // Kaiiju
|
||||
if (this.mob.isVehicle()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -68,6 +69,7 @@ public class RandomStrollGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
+ if (this.mob.isLobotomized()) return false; // Kaiiju
|
||||
return !this.mob.getNavigation().isDone() && !this.mob.isVehicle();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/TemptGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/TemptGoal.java
|
||||
index 2cbc9adc8e417def48be03d08174a5833068ec65..3234d5bf3b9ae01dbe8e26a0a3f21ff875fe6769 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/TemptGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/TemptGoal.java
|
||||
@@ -43,6 +43,7 @@ public class TemptGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
+ if (this.mob.isLobotomized()) return false; // Kaiiju
|
||||
if (this.calmDown > 0) {
|
||||
--this.calmDown;
|
||||
return false;
|
||||
@@ -67,6 +68,7 @@ public class TemptGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
+ if (this.mob.isLobotomized()) return false; // Kaiiju
|
||||
if (this.canScare()) {
|
||||
if (this.mob.distanceToSqr((Entity) this.player) < 36.0D) {
|
||||
if (this.player.distanceToSqr(this.px, this.py, this.pz) > 0.010000000000000002D) {
|
||||
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 2f2d9bb31194618ef5bba39cd1cbe7c4919e82c5..0d8f1f063b76357374022e4496ce0646757b150e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
@@ -197,6 +197,7 @@ public abstract class PathNavigation {
|
||||
// Paper end
|
||||
|
||||
public boolean moveTo(Entity entity, double speed) {
|
||||
+ if (this.mob.isLobotomized()) return false; // Kaiiju
|
||||
// Paper start - Pathfinding optimizations
|
||||
if (this.pathfindFailures > 10 && this.path == null && net.minecraft.server.MinecraftServer.currentTick < this.lastFailure + 40) {
|
||||
return false;
|
||||
@@ -217,6 +218,7 @@ public abstract class PathNavigation {
|
||||
}
|
||||
|
||||
public boolean moveTo(@Nullable Path path, double speed) {
|
||||
+ if (this.mob.isLobotomized()) return false; // Kaiiju
|
||||
if (path == null) {
|
||||
this.path = null;
|
||||
return false;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Animal.java b/src/main/java/net/minecraft/world/entity/animal/Animal.java
|
||||
index 2ac88f06ebb79e515cd9934ac1e3e2c8003d9e3c..d89c0db4c4173d8558dc4f8b15ddb5815ef7c09e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Animal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Animal.java
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
-import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.AgeableMob;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
@@ -39,6 +38,7 @@ public abstract class Animal extends AgeableMob {
|
||||
@Nullable
|
||||
public UUID loveCause;
|
||||
public ItemStack breedItem; // CraftBukkit - Add breedItem variable
|
||||
+ protected dev.kaiijumc.kaiiju.entity.Lobotomized lobotomized = new dev.kaiijumc.kaiiju.entity.Lobotomized(); // Kaiiju
|
||||
public abstract int getPurpurBreedTime(); // Purpur
|
||||
|
||||
protected Animal(EntityType<? extends Animal> type, Level world) {
|
||||
@@ -74,8 +74,32 @@ public abstract class Animal extends AgeableMob {
|
||||
}
|
||||
}
|
||||
|
||||
+ this.lobotomized.checkLobotomized(this); // Kaiiju
|
||||
}
|
||||
|
||||
+ // Kaiiju start
|
||||
+ @Override
|
||||
+ public void travel(net.minecraft.world.phys.Vec3 vec3) {
|
||||
+ if (!this.isLobotomized() || net.minecraft.server.MinecraftServer.currentTick % 100 == 0) {
|
||||
+ super.travel(vec3);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) {
|
||||
+ if (!this.isLobotomized() || net.minecraft.server.MinecraftServer.currentTick % 20 == 0) {
|
||||
+ return super.isCollidable(ignoreClimbing);
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isLobotomized() {
|
||||
+ if (!this.level.kaiijuConfig.lobotomizeAnimalEnabled) return false;
|
||||
+ return this.lobotomized.isLobotomized();
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
/* CraftBukkit start
|
||||
// Function disabled as it has no special function anymore after
|
||||
// setSitting is disabled.
|
||||
@@ -102,6 +126,7 @@ public abstract class Animal extends AgeableMob {
|
||||
if (this.loveCause != null) {
|
||||
nbt.putUUID("LoveCause", this.loveCause);
|
||||
}
|
||||
+ nbt.putBoolean("Kaiiju.Lobotomized", this.lobotomized.isLobotomized()); // Kaiiju
|
||||
|
||||
}
|
||||
|
||||
@@ -115,6 +140,13 @@ public abstract class Animal extends AgeableMob {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
this.inLove = nbt.getInt("InLove");
|
||||
this.loveCause = nbt.hasUUID("LoveCause") ? nbt.getUUID("LoveCause") : null;
|
||||
+ // Kaiiju start
|
||||
+ boolean isLobotomized = nbt.getBoolean("Kaiiju.Lobotomized");
|
||||
+ this.lobotomized.setLobotomized(isLobotomized);
|
||||
+ if (isLobotomized) {
|
||||
+ this.onGround = true;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
}
|
||||
|
||||
public static boolean checkAnimalSpawnRules(EntityType<? extends Animal> type, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, RandomSource random) {
|
||||
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 87bd7991a81a2e30ecfccb60e614d7f13acd3744..1c2db953155498606f1e052580e7aa9ca846a53c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -1047,6 +1047,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canBeeUse() {
|
||||
+ if (Bee.this.isLobotomized()) return false; // Kaiiju
|
||||
return Bee.this.remainingCooldownBeforeLocatingNewHive == 0 && !Bee.this.hasHive() && Bee.this.wantsToEnterHive();
|
||||
}
|
||||
|
||||
@@ -1113,6 +1114,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canBeeUse() {
|
||||
+ if (Bee.this.isLobotomized()) return false; // Kaiiju
|
||||
return Bee.this.hivePos != null && !Bee.this.hasRestriction() && Bee.this.wantsToEnterHive() && !this.hasReachedTarget(Bee.this.hivePos) && Bee.this.level.getBlockState(Bee.this.hivePos).is(BlockTags.BEEHIVES);
|
||||
}
|
||||
|
||||
@@ -1229,6 +1231,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canBeeUse() {
|
||||
+ if (Bee.this.isLobotomized()) return false; // Kaiiju
|
||||
return Bee.this.savedFlowerPos != null && !Bee.this.hasRestriction() && this.wantsToGoToKnownFlower() && Bee.this.isFlowerValid(Bee.this.savedFlowerPos) && !Bee.this.closerThan(Bee.this.savedFlowerPos, 2);
|
||||
}
|
||||
|
||||
@@ -1281,6 +1284,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canBeeUse() {
|
||||
+ if (Bee.this.isLobotomized()) return false; // Kaiiju
|
||||
return Bee.this.getCropsGrownSincePollination() >= 10 ? false : (Bee.this.random.nextFloat() < 0.3F ? false : Bee.this.hasNectar() && Bee.this.isHiveValid());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Thu, 16 Feb 2023 01:49:54 +0200
|
||||
Subject: [PATCH] Purpur Network SendNullEntityPackets
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index 7c6d43d8a360530344ef296f4477750c8a298607..ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -198,7 +198,10 @@ public class KaiijuConfig {
|
||||
private static void regionFormatSettings() {
|
||||
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
||||
}
|
||||
+
|
||||
+ public static boolean sendNullEntityPackets = true;
|
||||
|
||||
private static void networkSettings() {
|
||||
+ sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index b7fd8e70413c38923d0719aff803449e392383ac..fc778cf828c42065a7928d2f920fc1442aa4d503 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -205,6 +205,11 @@ public class ServerEntity {
|
||||
flag4 = true;
|
||||
flag5 = true;
|
||||
}
|
||||
+ // Kaiiju start - Don't send null move entity packets
|
||||
+ if (!dev.kaiijumc.kaiiju.KaiijuConfig.sendNullEntityPackets && isNullMovePacket(packet1)) {
|
||||
+ packet1 = null;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
}
|
||||
|
||||
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
||||
@@ -279,6 +284,20 @@ public class ServerEntity {
|
||||
}));
|
||||
}
|
||||
|
||||
+ // Kaiiju start - Don't send null move entity packets
|
||||
+ private boolean isNullMovePacket(Packet<?> packet) {
|
||||
+ if (packet instanceof ClientboundMoveEntityPacket move) {
|
||||
+ if (packet instanceof ClientboundMoveEntityPacket.Pos)
|
||||
+ return move.getXa() == 0 && move.getYa() == 0 && move.getZa() == 0;
|
||||
+ if (packet instanceof ClientboundMoveEntityPacket.PosRot)
|
||||
+ return move.getXa() == 0 && move.getYa() == 0 && move.getZa() == 0 && move.getyRot() == 0 && move.getxRot() == 0;
|
||||
+ if (packet instanceof ClientboundMoveEntityPacket.Rot)
|
||||
+ return move.getyRot() == 0 && move.getxRot() == 0;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
public void removePairing(ServerPlayer player) {
|
||||
this.entity.stopSeenByPlayer(player);
|
||||
player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()}));
|
||||
@@ -1,157 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kugge <sofiane.djerbi38@gmail.com>
|
||||
Date: Mon, 13 Feb 2023 00:53:40 +0100
|
||||
Subject: [PATCH] Kaiiju Lobotomize Villager
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index dbbba258dbdc465b89c71508d76c5c596fd03bea..a213a3c447cd69b5dd88eefd48c2caa6d19f5abc 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -127,11 +127,21 @@ public class KaiijuWorldConfig {
|
||||
public int lobotomizeAnimalCheckInterval = 100;
|
||||
public boolean lobotomizeAnimalLookAtPlayer = false;
|
||||
public boolean lobotomizeAnimalFloat = true;
|
||||
+ public boolean lobotomizeVillagerEnabled = false;
|
||||
+ public int lobotomizeVillagerCheckInterval = 100;
|
||||
+ public boolean lobotomizeVillagerCheckCanJump = true;
|
||||
+ public boolean lobotomizeVillagerCheckOnBed = true;
|
||||
+ public boolean lobotomizeVillagerCheckActionBlock = true;
|
||||
|
||||
private void lobotomizeSettings() {
|
||||
lobotomizeAnimalEnabled = getBoolean("lobotomize.animal.enabled", lobotomizeAnimalEnabled);
|
||||
lobotomizeAnimalCheckInterval = getInt("lobotomize.animal.check-interval", lobotomizeAnimalCheckInterval);
|
||||
lobotomizeAnimalLookAtPlayer = getBoolean("lobotomize.animal.look-at-player", lobotomizeAnimalLookAtPlayer);
|
||||
lobotomizeAnimalFloat = getBoolean("lobotomize.animal.float", lobotomizeAnimalFloat);
|
||||
+ lobotomizeVillagerEnabled = getBoolean("lobotomize.villager.enabled", lobotomizeVillagerEnabled);
|
||||
+ lobotomizeVillagerCheckInterval = getInt("lobotomize.villager.check-interval", lobotomizeVillagerCheckInterval);
|
||||
+ lobotomizeVillagerCheckCanJump = getBoolean("lobotomize.villager.check-can-jump", lobotomizeVillagerCheckCanJump);
|
||||
+ lobotomizeVillagerCheckOnBed = getBoolean("lobotomize.villager.check-on-bed", lobotomizeVillagerCheckOnBed);
|
||||
+ lobotomizeVillagerCheckActionBlock = getBoolean("lobotomize.villager.check-action-block", lobotomizeVillagerCheckActionBlock);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
index aed1d9ccffe471b6c2a1d52d2d3d097f6431318b..0227e8d4f810c6fb90779cb3d257ca04ec927b79 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -200,14 +200,14 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
|
||||
private boolean checkLobotomized() {
|
||||
- int interval = this.level.purpurConfig.villagerLobotomizeCheckInterval;
|
||||
+ int interval = this.level.kaiijuConfig.lobotomizeVillagerCheckInterval; // Kaiiju
|
||||
if (this.notLobotomizedCount > 3) {
|
||||
// check half as often if not lobotomized for the last 3+ consecutive checks
|
||||
interval *= 2;
|
||||
}
|
||||
- if (this.level.getGameTime() % interval == 0) {
|
||||
+ if ((this.getId() + this.tickCount) % interval == 0) { // Kaiiju - Avoid check lags
|
||||
// offset Y for short blocks like dirt_path/farmland
|
||||
- this.isLobotomized = !canTravelFrom(new BlockPos(getX(), getY() + 0.0625D, getZ()));
|
||||
+ this.isLobotomized = needLobotomy(); // Kaiiju - Override
|
||||
|
||||
if (this.isLobotomized) {
|
||||
this.notLobotomizedCount = 0;
|
||||
@@ -219,9 +219,76 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
|
||||
private boolean canTravelFrom(BlockPos pos) {
|
||||
- return canTravelTo(pos.east()) || canTravelTo(pos.west()) || canTravelTo(pos.north()) || canTravelTo(pos.south());
|
||||
+ return canInteractAt(pos.east()) || canInteractAt(pos.west()) || canInteractAt(pos.north()) || canInteractAt(pos.south()); // Kaiiju
|
||||
}
|
||||
|
||||
+ // Kaiiju start - Customize canTravelTo checks
|
||||
+ private boolean needLobotomy() {
|
||||
+ if (this.isSleeping()) return false;
|
||||
+ if (this.level.kaiijuConfig.lobotomizeVillagerCheckOnBed && isOnBed()) return false;
|
||||
+ return !canTravelFrom(new BlockPos(getX(), getY() + 0.5D, getZ()));
|
||||
+ }
|
||||
+
|
||||
+ private boolean canInteractAt(BlockPos pos) {
|
||||
+ net.minecraft.world.level.block.state.BlockState top = null;
|
||||
+ // Check if mob can jump over block
|
||||
+ if (this.level.kaiijuConfig.lobotomizeVillagerCheckCanJump && this.canJump()) {
|
||||
+ top = this.level.getBlockStateIfLoaded(pos.above());
|
||||
+ if (top == null) return false;
|
||||
+ if (top.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND)) {
|
||||
+ net.minecraft.world.level.block.state.BlockState above = this.level.getBlockState(pos.above(2));
|
||||
+ if (above.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND)) return true;
|
||||
+ }
|
||||
+ }
|
||||
+ // Otherwise, check if mob can interact with bottom block
|
||||
+ net.minecraft.world.level.block.state.BlockState bottom = this.level.getBlockStateIfLoaded(pos);
|
||||
+ if (bottom == null) return false;
|
||||
+ net.minecraft.world.level.block.Block bottomBlock = bottom.getBlock();
|
||||
+ if (isTallBlock(bottomBlock)) return false;
|
||||
+ if (this.level.kaiijuConfig.lobotomizeVillagerCheckActionBlock && isInteractiveBlock(bottomBlock, this.getVillagerData().getProfession())) return true;
|
||||
+ // If he can't interact, check if he can travel
|
||||
+ if (!bottom.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND)) return false;
|
||||
+ if (top == null) top = this.level.getBlockState(pos.above());
|
||||
+ return top.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND);
|
||||
+ }
|
||||
+
|
||||
+ private boolean canJump() {
|
||||
+ BlockPos pos = new BlockPos(getX(), getY() + 2.5D, getZ());
|
||||
+ net.minecraft.world.level.block.Block above = this.level.getBlockIfLoaded(pos);
|
||||
+ return !above.hasCollision;
|
||||
+ }
|
||||
+
|
||||
+ private boolean isOnBed() {
|
||||
+ BlockPos pos = new BlockPos(getX(), getY() - 0.5D, getZ());
|
||||
+ net.minecraft.world.level.block.Block below = this.level.getBlockIfLoaded(pos);
|
||||
+ return below instanceof net.minecraft.world.level.block.BedBlock;
|
||||
+ }
|
||||
+
|
||||
+ private static boolean isInteractiveBlock(net.minecraft.world.level.block.Block block, VillagerProfession profession) {
|
||||
+ if (block instanceof net.minecraft.world.level.block.BedBlock) return true;
|
||||
+ if (profession == VillagerProfession.NITWIT) return false;
|
||||
+ return (block instanceof net.minecraft.world.level.block.BlastFurnaceBlock && profession != VillagerProfession.ARMORER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.SmokerBlock && profession != VillagerProfession.BUTCHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.CartographyTableBlock && profession != VillagerProfession.CARTOGRAPHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.BrewingStandBlock && profession != VillagerProfession.CLERIC) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.ComposterBlock && profession != VillagerProfession.FARMER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.BarrelBlock && profession != VillagerProfession.FISHERMAN) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.FletchingTableBlock && profession != VillagerProfession.FLETCHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.CauldronBlock && profession != VillagerProfession.LEATHERWORKER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.LecternBlock && profession != VillagerProfession.LIBRARIAN) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.StonecutterBlock && profession != VillagerProfession.MASON) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.LoomBlock && profession != VillagerProfession.SHEPHERD) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.SmithingTableBlock && profession != VillagerProfession.TOOLSMITH) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.GrindstoneBlock && profession != VillagerProfession.WEAPONSMITH);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean isTallBlock(net.minecraft.world.level.block.Block block) {
|
||||
+ return block instanceof net.minecraft.world.level.block.FenceBlock ||
|
||||
+ block instanceof net.minecraft.world.level.block.FenceGateBlock ||
|
||||
+ block instanceof net.minecraft.world.level.block.WallBlock;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
private boolean canTravelTo(BlockPos pos) {
|
||||
net.minecraft.world.level.block.state.BlockState state = this.level.getBlockStateIfLoaded(pos);
|
||||
if (state == null) {
|
||||
@@ -337,7 +404,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
protected void mobTick(boolean inactive) {
|
||||
//this.level.getProfiler().push("villagerBrain"); // Purpur
|
||||
// Purpur start
|
||||
- if (this.level.purpurConfig.villagerLobotomizeEnabled) {
|
||||
+ if (this.level.kaiijuConfig.lobotomizeVillagerEnabled) { // Kaiiju - Override
|
||||
// treat as inactive if lobotomized
|
||||
inactive = inactive || checkLobotomized();
|
||||
} else {
|
||||
@@ -647,6 +714,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
if (this.assignProfessionWhenSpawned) {
|
||||
nbt.putBoolean("AssignProfessionWhenSpawned", true);
|
||||
}
|
||||
+ nbt.putBoolean("Kaiiju.Lobotomized", this.isLobotomized()); // Kaiiju
|
||||
|
||||
}
|
||||
|
||||
@@ -687,6 +755,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
if (nbt.contains("AssignProfessionWhenSpawned")) {
|
||||
this.assignProfessionWhenSpawned = nbt.getBoolean("AssignProfessionWhenSpawned");
|
||||
}
|
||||
+ this.isLobotomized = nbt.getBoolean("Kaiiju.Lobotomized"); // Kaiiju
|
||||
|
||||
}
|
||||
|
||||
71
patches/server/0007-Purpur-Network-AlternateKeepalive.patch
Normal file
71
patches/server/0007-Purpur-Network-AlternateKeepalive.patch
Normal file
@@ -0,0 +1,71 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Fri, 31 Mar 2023 01:52:44 +0300
|
||||
Subject: [PATCH] Purpur Network AlternateKeepalive
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7..b42a3466f145a92608c8746fd4beb529b4a60b01 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -200,8 +200,10 @@ public class KaiijuConfig {
|
||||
}
|
||||
|
||||
public static boolean sendNullEntityPackets = true;
|
||||
+ public static boolean alternateKeepAlive = false;
|
||||
|
||||
private static void networkSettings() {
|
||||
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||
+ alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 4963e87adf11c9df90f0dd4b60d360a137c07bc9..5f73e794a248a4d11b58b169831622ca1f61aac6 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -261,6 +261,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
private long keepAliveTime = Util.getMillis();
|
||||
private boolean keepAlivePending;
|
||||
private long keepAliveChallenge;
|
||||
+ private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Kaiiju
|
||||
// CraftBukkit start - multithreaded fields
|
||||
private final AtomicInteger chatSpamTickCount = new AtomicInteger();
|
||||
private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
|
||||
@@ -352,6 +353,20 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
long currentTime = Util.getMillis();
|
||||
long elapsedTime = currentTime - this.keepAliveTime;
|
||||
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.alternateKeepAlive) {
|
||||
+ if (elapsedTime >= 1000L) { // 1 second
|
||||
+ if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) {
|
||||
+ LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName());
|
||||
+ disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
|
||||
+ } else {
|
||||
+ keepAliveTime = currentTime; // hijack this field for 1 second intervals
|
||||
+ keepAlives.add(currentTime); // currentTime is ID
|
||||
+ send(new ClientboundKeepAlivePacket(currentTime));
|
||||
+ }
|
||||
+ }
|
||||
+ } else
|
||||
+ // Kaiiju end
|
||||
if (this.keepAlivePending) {
|
||||
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
|
||||
@@ -3534,6 +3549,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.alternateKeepAlive) {
|
||||
+ long id = packet.getId();
|
||||
+ if (keepAlives.size() > 0 && keepAlives.contains(id)) {
|
||||
+ int ping = (int) (Util.getMillis() - id);
|
||||
+ player.latency = (player.latency * 3 + ping) / 4;
|
||||
+ keepAlives.clear(); // we got a valid response, lets roll with it and forget the rest
|
||||
+ }
|
||||
+ } else
|
||||
+ // Kaiiju end
|
||||
//PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread
|
||||
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (Util.getMillis() - this.keepAliveTime);
|
||||
31
patches/server/0008-Kaiiju-Gameplay-Configuration.patch
Normal file
31
patches/server/0008-Kaiiju-Gameplay-Configuration.patch
Normal file
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Sat, 8 Apr 2023 23:32:34 +0300
|
||||
Subject: [PATCH] Kaiiju Gameplay Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index b42a3466f145a92608c8746fd4beb529b4a60b01..6d0e1edfb7d3c020f70f6a194f16e836b462c4de 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -206,4 +206,7 @@ public class KaiijuConfig {
|
||||
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
||||
}
|
||||
+
|
||||
+ private static void gameplaySettings() {
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index b194f4dbebcbbf5bb4e026a0169e2d24806b46ec..73d79fe0077b28db2f9e7fa13a1ae6eff9abd6a9 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -143,4 +143,7 @@ public class KaiijuWorldConfig {
|
||||
regionFormatLinearCompressionLevel = 1;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ private void gameplaySettings() {
|
||||
+ }
|
||||
}
|
||||
\ No newline at end of file
|
||||
@@ -0,0 +1,34 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Xymb <xymb@endcrystal.me>
|
||||
Date: Sat, 8 Apr 2023 23:38:13 +0300
|
||||
Subject: [PATCH] Kaiiju Gameplay ShulkerDropContentsWhenDestroyed
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index 73d79fe0077b28db2f9e7fa13a1ae6eff9abd6a9..bac11b0e30a86d0689693ff129b53bcad7c2034c 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -144,6 +144,9 @@ public class KaiijuWorldConfig {
|
||||
}
|
||||
}
|
||||
|
||||
+ public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||
+
|
||||
private void gameplaySettings() {
|
||||
+ shulkerBoxDropContentsWhenDestroyed = getBoolean("gameplay.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||
}
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||
index b0204af850ee182773ad458208cccd946ad148d5..cb67928eb9d493b4c43489aa06a5c0c947999dac 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||
@@ -288,7 +288,7 @@ public class BlockItem extends Item {
|
||||
|
||||
@Override
|
||||
public void onDestroyed(ItemEntity entity) {
|
||||
- if (this.block instanceof ShulkerBoxBlock) {
|
||||
+ if (this.block instanceof ShulkerBoxBlock && entity.getLevel().kaiijuConfig.shulkerBoxDropContentsWhenDestroyed) { // Kaiiju
|
||||
ItemStack itemstack = entity.getItem();
|
||||
CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
|
||||
|
||||
33
patches/server/0010-Purpur-Gameplay-ServerModName.patch
Normal file
33
patches/server/0010-Purpur-Gameplay-ServerModName.patch
Normal file
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Sun, 9 Apr 2023 17:06:46 +0300
|
||||
Subject: [PATCH] Purpur Gameplay ServerModName
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index 6d0e1edfb7d3c020f70f6a194f16e836b462c4de..9fb33b35b4d6842ca8597f77a4116e3983ebfbcb 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -207,6 +207,9 @@ public class KaiijuConfig {
|
||||
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
||||
}
|
||||
|
||||
+ public static String serverModName = "Kaiiju";
|
||||
+
|
||||
private static void gameplaySettings() {
|
||||
+ serverModName = getString("gameplay.server-mod-name", serverModName);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index a7233bcc99e9bf148348ebb36bbb15b2eadb381f..865b022bb52d8d7b12355a01f3216a4ee8d4c045 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1833,7 +1833,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Kaiiju"; // Kaiiju - Kaiiju > // Folia - Folia > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
+ return dev.kaiijumc.kaiiju.KaiijuConfig.serverModName; // Kaiiju - Kaiiju > // Folia - Folia > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
228
patches/server/0011-Kaiiju-Linear-CrashOnBrokenSymlink.patch
Normal file
228
patches/server/0011-Kaiiju-Linear-CrashOnBrokenSymlink.patch
Normal file
@@ -0,0 +1,228 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Xymb <xymb@endcrystal.me>
|
||||
Date: Fri, 14 Apr 2023 02:12:58 +0200
|
||||
Subject: [PATCH] Kaiiju Linear CrashOnBrokenSymlink
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index bac11b0e30a86d0689693ff129b53bcad7c2034c..0f0cfd958f7d2c6d2ca4192be1b986900a2bfa53 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -127,6 +127,7 @@ public class KaiijuWorldConfig {
|
||||
|
||||
public List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
|
||||
public String regionFormatName = "ANVIL";
|
||||
+ public boolean linearCrashOnBrokenSymlink = true;
|
||||
public int regionFormatLinearCompressionLevel = 1;
|
||||
|
||||
private void regionFormatSettings() {
|
||||
@@ -142,6 +143,7 @@ public class KaiijuWorldConfig {
|
||||
log(Level.SEVERE, "Falling back to compression level 1.");
|
||||
regionFormatLinearCompressionLevel = 1;
|
||||
}
|
||||
+ linearCrashOnBrokenSymlink = getBoolean("region-format.linear.crash-on-broken-symlink", linearCrashOnBrokenSymlink);
|
||||
}
|
||||
|
||||
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
index a62a1b281bd0b6ad7d59b45b9470d84f496f6539..7f87dfa131ab7d40a94cf6355765478f2961342e 100644
|
||||
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
@@ -86,10 +86,11 @@ public class ThreadedWorldUpgrader {
|
||||
// Kaiiju start
|
||||
String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
||||
int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||
+ boolean linearCrashOnBrokenSymlink = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.linearCrashOnBrokenSymlink;
|
||||
LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
|
||||
// Kaiiju end
|
||||
final WorldInfo info = new WorldInfo(() -> worldPersistentData,
|
||||
- new ChunkStorage(formatName, linearCompression, regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey); // Kaiiju
|
||||
+ new ChunkStorage(formatName, linearCompression, linearCrashOnBrokenSymlink, regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey); // Kaiiju
|
||||
|
||||
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 43503974433c4d1808b2acb2b79f46d640725dc0..73ac94eaebdeaa94c83f1f23b53e686d867e6f98 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -272,7 +272,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper end
|
||||
|
||||
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
||||
- super(world.getLevel().kaiijuConfig.regionFormatName, world.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
|
||||
+ super(world.getLevel().kaiijuConfig.regionFormatName, world.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, world.getLevel().kaiijuConfig.linearCrashOnBrokenSymlink, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
|
||||
// Paper - rewrite chunk system
|
||||
this.tickingGenerated = new AtomicInteger();
|
||||
//this.playerMap = new PlayerMap(); // Folia - region threading
|
||||
@@ -317,7 +317,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.lightEngine = new ThreadedLevelLightEngine(chunkProvider, this, this.level.dimensionType().hasSkyLight(), null, null); // Paper - rewrite chunk system
|
||||
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
||||
this.overworldDataStorage = persistentStateManagerFactory;
|
||||
- this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||
+ this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, this.level.kaiijuConfig.linearCrashOnBrokenSymlink, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||
this.setViewDistance(viewDistance);
|
||||
// Paper start
|
||||
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 20359c63b19c7e0c703ef1562fb774803d631c41..35ae624be25b66d5615dc19cbe7eb8785c7029b5 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -425,8 +425,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
private final EntityRegionFileStorage entityStorage;
|
||||
|
||||
private static final class EntityRegionFileStorage extends net.minecraft.world.level.chunk.storage.RegionFileStorage {
|
||||
- public EntityRegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
||||
- super(format, linearCompression, directory, dsync); // Kaiiju
|
||||
+ public EntityRegionFileStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync) { // Kaiiju
|
||||
+ super(format, linearCompression, linearCrashOnBrokenSymlink, directory, dsync); // Kaiiju
|
||||
}
|
||||
|
||||
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
|
||||
@@ -632,7 +632,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// CraftBukkit end
|
||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||
- this.entityStorage = new EntityRegionFileStorage(this.getLevel().kaiijuConfig.regionFormatName, this.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); // Kaiiju
|
||||
+ this.entityStorage = new EntityRegionFileStorage(this.getLevel().kaiijuConfig.regionFormatName, this.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, this.getLevel().kaiijuConfig.linearCrashOnBrokenSymlink, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); // Kaiiju
|
||||
|
||||
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
|
||||
StructureTemplateManager structuretemplatemanager = minecraftserver.getStructureManager();
|
||||
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
index 469802b9c454c5e98c0a55ba89559d9d8ba0c4c0..1652398c211c4366dde1d973bdb8e9d2c5c67ff4 100644
|
||||
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
@@ -119,7 +119,8 @@ public class WorldUpgrader {
|
||||
String worldName = this.levelStorage.getLevelId();
|
||||
String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
||||
int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||
- builder1.put(resourcekey1, new ChunkStorage(formatName, linearCompression, path.resolve("region"), this.dataFixer, true));
|
||||
+ boolean linearCrashOnBrokenSymlink = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.linearCrashOnBrokenSymlink;
|
||||
+ builder1.put(resourcekey1, new ChunkStorage(formatName, linearCompression, linearCrashOnBrokenSymlink, path.resolve("region"), this.dataFixer, true));
|
||||
// Kaiiju end
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
index f560aa13c6c8ffecb456f478687dc6a9eb5e8017..f0354203f974a8d7440407a5561ffa0fcb63182d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
@@ -59,8 +59,8 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
||||
// Paper end - rewrite chunk system
|
||||
|
||||
|
||||
- public PoiManager(String formatName, int linearCompression, Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) { // Kaiiju
|
||||
- super(formatName, linearCompression, path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world); // Kaiiju
|
||||
+ public PoiManager(String formatName, int linearCompression, boolean linearCrashOnBrokenSymlink, Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) { // Kaiiju
|
||||
+ super(formatName, linearCompression, linearCrashOnBrokenSymlink, path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world); // Kaiiju
|
||||
this.world = (net.minecraft.server.level.ServerLevel)world; // Paper - rewrite chunk system
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
index 52c2e0fe73a5af18535a2b0b9a506919e3f93003..ea54af3f68c6534ff5a71ca0b7a99d126557868e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
@@ -37,12 +37,12 @@ public class ChunkStorage implements AutoCloseable {
|
||||
public final RegionFileStorage regionFileCache;
|
||||
// Paper end - async chunk loading
|
||||
|
||||
- public ChunkStorage(String format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
||||
+ public ChunkStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
||||
this.fixerUpper = dataFixer;
|
||||
|
||||
// Paper start - async chunk io
|
||||
// remove IO worker
|
||||
- this.regionFileCache = new RegionFileStorage(format, linearCompression, directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
+ this.regionFileCache = new RegionFileStorage(format, linearCompression, linearCrashOnBrokenSymlink, directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
// Paper end - async chunk io
|
||||
}
|
||||
|
||||
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 c9fbba6f709ed0540dcc22b41e50ce9d01a6381c..70e3ee306283263cdcdb7a66c80fc23484385aac 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
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||
|
||||
public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Kaiiju
|
||||
public static final String ANVIL_EXTENSION = ".mca";
|
||||
private static final int MAX_CACHE_SIZE = 256;
|
||||
public final Long2ObjectLinkedOpenHashMap<dev.kaiijumc.kaiiju.region.AbstractRegionFile> regionCache = new Long2ObjectLinkedOpenHashMap(); // Kaiiju
|
||||
@@ -28,6 +29,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
// Kaiiju start - Per world chunk format
|
||||
public final String format;
|
||||
public final int linearCompression;
|
||||
+ public final boolean linearCrashOnBrokenSymlink;
|
||||
// Kaiiju end
|
||||
|
||||
private final boolean isChunkData; // Paper
|
||||
@@ -61,14 +63,15 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
// Paper end - cache regionfile does not exist state
|
||||
|
||||
- protected RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Paper - protected constructor
|
||||
+ protected RegionFileStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync) { // Paper - protected constructor
|
||||
// Paper start - add isChunkData param
|
||||
- this(format, linearCompression, directory, dsync, false);
|
||||
+ this(format, linearCompression, linearCrashOnBrokenSymlink, directory, dsync, false);
|
||||
}
|
||||
- RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
||||
+ RegionFileStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
||||
// Kaiiju start
|
||||
this.format = format;
|
||||
this.linearCompression = linearCompression;
|
||||
+ this.linearCrashOnBrokenSymlink = linearCrashOnBrokenSymlink;
|
||||
// Kaiiju end
|
||||
this.isChunkData = isChunkData;
|
||||
// Paper end - add isChunkData param
|
||||
@@ -109,6 +112,20 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
return regionfile != null ? regionfile.hasChunk(pos) : false;
|
||||
}
|
||||
|
||||
+ // Kaiiju start
|
||||
+ private void guardAgainstBrokenSymlinks(Path path) throws IOException {
|
||||
+ if (!linearCrashOnBrokenSymlink) return;
|
||||
+ if (!this.format.equals("LINEAR")) return;
|
||||
+ if (!java.nio.file.Files.isSymbolicLink(path)) return;
|
||||
+ Path link = java.nio.file.Files.readSymbolicLink(path);
|
||||
+ if (!java.nio.file.Files.exists(link) || !java.nio.file.Files.isReadable(link)) {
|
||||
+ LOGGER.error("Linear region file {} is a broken symbolic link, crashing to prevent data loss", path);
|
||||
+ net.minecraft.server.MinecraftServer.getServer().halt(false);
|
||||
+ throw new IOException("Linear region file " + path + " is a broken symbolic link, crashing to prevent data loss");
|
||||
+ }
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
public synchronized dev.kaiijumc.kaiiju.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Kaiiju
|
||||
return this.getRegionFile(chunkcoordintpair, existingOnly, false);
|
||||
}
|
||||
@@ -144,6 +161,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
if (existingOnly) {
|
||||
Path anvil = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||
Path linear = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
|
||||
+ guardAgainstBrokenSymlinks(linear);
|
||||
if (java.nio.file.Files.exists(anvil)) path1 = anvil;
|
||||
else if (java.nio.file.Files.exists(linear)) path1 = linear;
|
||||
else {
|
||||
@@ -156,6 +174,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
default -> "mca";
|
||||
};
|
||||
path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension);
|
||||
+ guardAgainstBrokenSymlinks(path1);
|
||||
this.createRegionFile(regionPos);
|
||||
}
|
||||
if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatDebug)
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
index 414aa3ae00c2d28e754235e3e93b6b623d4fd180..15e376fac063430e4355c6ffcd25c35a8ce20c5b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
@@ -47,8 +47,8 @@ public class SectionStorage<R> extends RegionFileStorage implements AutoCloseabl
|
||||
public final RegistryAccess registryAccess; // Paper - rewrite chunk system
|
||||
protected final LevelHeightAccessor levelHeightAccessor;
|
||||
|
||||
- public SectionStorage(String format, int linearCompression, Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) { // Kaiiju
|
||||
- super(format, linearCompression, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
|
||||
+ public SectionStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) { // Kaiiju
|
||||
+ super(format, linearCompression, linearCrashOnBrokenSymlink, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
|
||||
this.codec = codecFactory;
|
||||
this.factory = factory;
|
||||
this.fixerUpper = dataFixer;
|
||||
35
patches/server/0012-Purpur-Gameplay-FixVoidTrading.patch
Normal file
35
patches/server/0012-Purpur-Gameplay-FixVoidTrading.patch
Normal file
@@ -0,0 +1,35 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Sun, 23 Apr 2023 15:34:30 +0300
|
||||
Subject: [PATCH] Purpur Gameplay FixVoidTrading
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index 0f0cfd958f7d2c6d2ca4192be1b986900a2bfa53..c267b0cd52448246c7701081028ff0986dde2fa2 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -147,8 +147,10 @@ public class KaiijuWorldConfig {
|
||||
}
|
||||
|
||||
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||
+ public boolean fixVoidTrading = true;
|
||||
|
||||
private void gameplaySettings() {
|
||||
shulkerBoxDropContentsWhenDestroyed = getBoolean("gameplay.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||
+ fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||
}
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 35ae624be25b66d5615dc19cbe7eb8785c7029b5..92cc38353d25f3749186dbc062402c9bafb25fca 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -2824,7 +2824,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// Spigot Start
|
||||
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
||||
// Paper start
|
||||
- if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
|
||||
+ if (entity.level.kaiijuConfig.fixVoidTrading && entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) { // Kaiiju
|
||||
merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED);
|
||||
}
|
||||
// Paper end
|
||||
219
patches/server/0013-Kaiiju-Gameplay-OptimizeHoppersToggle.patch
Normal file
219
patches/server/0013-Kaiiju-Gameplay-OptimizeHoppersToggle.patch
Normal file
@@ -0,0 +1,219 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Thu, 27 Apr 2023 03:49:08 +0300
|
||||
Subject: [PATCH] Kaiiju Gameplay OptimizeHoppersToggle
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index c267b0cd52448246c7701081028ff0986dde2fa2..2624e074e0a14f5e05aca8fa910b5e5d71f320a9 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -148,9 +148,11 @@ public class KaiijuWorldConfig {
|
||||
|
||||
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||
public boolean fixVoidTrading = true;
|
||||
+ public boolean optimizeHoppers = true;
|
||||
|
||||
private void gameplaySettings() {
|
||||
shulkerBoxDropContentsWhenDestroyed = getBoolean("gameplay.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||
+ optimizeHoppers = getBoolean("gameplay.optimize-hoppers", optimizeHoppers);
|
||||
}
|
||||
}
|
||||
\ No newline at end of file
|
||||
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 0134370081182260d578ee1d8a16d544c03b6a0d..555d86f0a9132c2292470c60f263e59082f0c26e 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
|
||||
@@ -401,49 +401,51 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
if (HopperBlockEntity.isFullContainer(iinventory1, enumdirection)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // Kaiiju start - Toggle paper broken redstone
|
||||
// Paper start - replace logic; MAKE SURE TO CHECK FOR DIFFS ON UPDATES
|
||||
- return hopperPush(world, iinventory1, enumdirection, hopper);
|
||||
- // for (int i = 0; i < iinventory.getContainerSize(); ++i) {
|
||||
- // if (!iinventory.getItem(i).isEmpty()) {
|
||||
- // ItemStack itemstack = iinventory.getItem(i).copy();
|
||||
- // // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
|
||||
-
|
||||
- // // CraftBukkit start - Call event when pushing items into other inventories
|
||||
- // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
|
||||
-
|
||||
- // Inventory destinationInventory;
|
||||
- // // Have to special case large chests as they work oddly
|
||||
- // if (iinventory1 instanceof CompoundContainer) {
|
||||
- // destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory1);
|
||||
- // } else if (iinventory1.getOwner() != null) {
|
||||
- // destinationInventory = iinventory1.getOwner().getInventory();
|
||||
- // } else {
|
||||
- // destinationInventory = new CraftInventory(iinventory);
|
||||
- // }
|
||||
-
|
||||
- // InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
|
||||
- // world.getCraftServer().getPluginManager().callEvent(event);
|
||||
- // if (event.isCancelled()) {
|
||||
- // hopper.setItem(i, itemstack);
|
||||
- // hopper.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||
- // return false;
|
||||
- // }
|
||||
- // int origCount = event.getItem().getAmount(); // Spigot
|
||||
- // ItemStack itemstack1 = HopperBlockEntity.addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
|
||||
+ if (world.kaiijuConfig.optimizeHoppers) return hopperPush(world, iinventory1, enumdirection, hopper);
|
||||
+ for (int i = 0; i < iinventory.getContainerSize(); ++i) {
|
||||
+ if (!iinventory.getItem(i).isEmpty()) {
|
||||
+ ItemStack itemstack = iinventory.getItem(i).copy();
|
||||
+ // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
|
||||
+
|
||||
+ // CraftBukkit start - Call event when pushing items into other inventories
|
||||
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
|
||||
+
|
||||
+ Inventory destinationInventory;
|
||||
+ // Have to special case large chests as they work oddly
|
||||
+ if (iinventory1 instanceof CompoundContainer) {
|
||||
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory1);
|
||||
+ } else if (iinventory1.getOwner() != null) {
|
||||
+ destinationInventory = iinventory1.getOwner().getInventory();
|
||||
+ } else {
|
||||
+ destinationInventory = new CraftInventory(iinventory);
|
||||
+ }
|
||||
+
|
||||
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ hopper.setItem(i, itemstack);
|
||||
+ hopper.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||
+ return false;
|
||||
+ }
|
||||
+ int origCount = event.getItem().getAmount(); // Spigot
|
||||
+ ItemStack itemstack1 = HopperBlockEntity.addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
|
||||
// CraftBukkit end
|
||||
|
||||
- // if (itemstack1.isEmpty()) {
|
||||
- // iinventory1.setChanged();
|
||||
- // return true;
|
||||
- // }
|
||||
+ if (itemstack1.isEmpty()) {
|
||||
+ iinventory1.setChanged();
|
||||
+ return true;
|
||||
+ }
|
||||
|
||||
- // itemstack.shrink(origCount - itemstack1.getCount()); // Spigot
|
||||
- // iinventory.setItem(i, itemstack);
|
||||
- // }
|
||||
- // }
|
||||
+ itemstack.shrink(origCount - itemstack1.getCount()); // Spigot
|
||||
+ iinventory.setItem(i, itemstack);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- // return false;
|
||||
+ return false;
|
||||
// Paper end
|
||||
+ // Kaiiju end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -467,6 +469,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
if (iinventory != null) {
|
||||
Direction enumdirection = Direction.DOWN;
|
||||
|
||||
+ // Kaiiju start - toggle paper broken redstone
|
||||
+ if (!world.kaiijuConfig.optimizeHoppers)
|
||||
+ return HopperBlockEntity.isEmptyContainer(iinventory, enumdirection) ? false : HopperBlockEntity.getSlots(iinventory, enumdirection).anyMatch((i) -> {
|
||||
+ return HopperBlockEntity.a(hopper, iinventory, i, enumdirection, world); // Spigot
|
||||
+ });
|
||||
+ // Kaiiju end
|
||||
// Paper start - optimize hoppers and remove streams
|
||||
worldData.skipPullModeEventFire = worldData.skipHopperEvents; // Folia - region threading
|
||||
return !HopperBlockEntity.isEmptyContainer(iinventory, enumdirection) && anyMatch(iinventory, enumdirection, (item, i) -> {
|
||||
@@ -499,48 +507,50 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
private static boolean a(Hopper ihopper, Container iinventory, int i, Direction enumdirection, Level world) { // Spigot
|
||||
ItemStack itemstack = iinventory.getItem(i);
|
||||
|
||||
+ // Kaiiju start - toggle paper broken redstone
|
||||
// Paper start - replace pull logic; MAKE SURE TO CHECK FOR DIFFS WHEN UPDATING
|
||||
if (!itemstack.isEmpty() && HopperBlockEntity.canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { // If this logic changes, update above. this is left unused incase reflective plugins
|
||||
- return hopperPull(world, ihopper, iinventory, itemstack, i);
|
||||
- // ItemStack itemstack1 = itemstack.copy();
|
||||
- // // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
|
||||
- // // CraftBukkit start - Call event on collection of items from inventories into the hopper
|
||||
- // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
|
||||
-
|
||||
- // Inventory sourceInventory;
|
||||
- // // Have to special case large chests as they work oddly
|
||||
- // if (iinventory instanceof CompoundContainer) {
|
||||
- // sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory);
|
||||
- // } else if (iinventory.getOwner() != null) {
|
||||
- // sourceInventory = iinventory.getOwner().getInventory();
|
||||
- // } else {
|
||||
- // sourceInventory = new CraftInventory(iinventory);
|
||||
- // }
|
||||
-
|
||||
- // InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
|
||||
-
|
||||
- // Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
- // if (event.isCancelled()) {
|
||||
- // iinventory.setItem(i, itemstack1);
|
||||
-
|
||||
- // if (ihopper instanceof HopperBlockEntity) {
|
||||
- // ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||
- // }
|
||||
-
|
||||
- // return false;
|
||||
- // }
|
||||
- // int origCount = event.getItem().getAmount(); // Spigot
|
||||
- // ItemStack itemstack2 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
|
||||
- // // CraftBukkit end
|
||||
-
|
||||
- // if (itemstack2.isEmpty()) {
|
||||
- // iinventory.setChanged();
|
||||
- // return true;
|
||||
- // }
|
||||
-
|
||||
- // itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot
|
||||
- // iinventory.setItem(i, itemstack1);
|
||||
+ if (world.kaiijuConfig.optimizeHoppers) return hopperPull(world, ihopper, iinventory, itemstack, i);
|
||||
+ ItemStack itemstack1 = itemstack.copy();
|
||||
+ // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
|
||||
+ // CraftBukkit start - Call event on collection of items from inventories into the hopper
|
||||
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
|
||||
+
|
||||
+ Inventory sourceInventory;
|
||||
+ // Have to special case large chests as they work oddly
|
||||
+ if (iinventory instanceof CompoundContainer) {
|
||||
+ sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory);
|
||||
+ } else if (iinventory.getOwner() != null) {
|
||||
+ sourceInventory = iinventory.getOwner().getInventory();
|
||||
+ } else {
|
||||
+ sourceInventory = new CraftInventory(iinventory);
|
||||
+ }
|
||||
+
|
||||
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
|
||||
+
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ iinventory.setItem(i, itemstack1);
|
||||
+
|
||||
+ if (ihopper instanceof HopperBlockEntity) {
|
||||
+ ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+ int origCount = event.getItem().getAmount(); // Spigot
|
||||
+ ItemStack itemstack2 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ if (itemstack2.isEmpty()) {
|
||||
+ iinventory.setChanged();
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot
|
||||
+ iinventory.setItem(i, itemstack1);
|
||||
// Paper end
|
||||
+ // Kaiiju end
|
||||
}
|
||||
|
||||
return false;
|
||||
101
patches/todo/0012-Static-Distance-WIP.patch
Normal file
101
patches/todo/0012-Static-Distance-WIP.patch
Normal file
@@ -0,0 +1,101 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Wed, 19 Apr 2023 02:37:04 +0300
|
||||
Subject: [PATCH] Static Distance WIP
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||
index e77972c4c264100ffdd824bfa2dac58dbbc6d678..cddacd6d5bbe97641bd23f5c067012907d9c5c01 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||
@@ -75,6 +75,17 @@ public final class PlayerChunkLoader {
|
||||
return data.getTargetSendViewDistance();
|
||||
}
|
||||
|
||||
+ // Kaiiju start - Static distance
|
||||
+ public static int getStaticDistance(final ServerPlayer player) {
|
||||
+ final ServerLevel level = (ServerLevel)player.level;
|
||||
+ final PlayerLoaderData data = level.chunkSource.chunkMap.playerChunkManager.getData(player);
|
||||
+ if (data == null) {
|
||||
+ return level.chunkSource.chunkMap.playerChunkManager.getTargetStaticDistance();
|
||||
+ }
|
||||
+ return data.getTargetSendViewDistance();
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
protected final ChunkMap chunkMap;
|
||||
protected final Reference2ObjectLinkedOpenHashMap<ServerPlayer, PlayerLoaderData> playerMap = new Reference2ObjectLinkedOpenHashMap<>(512, 0.7f);
|
||||
protected final ReferenceLinkedOpenHashSet<PlayerLoaderData> chunkSendQueue = new ReferenceLinkedOpenHashSet<>(512, 0.7f);
|
||||
@@ -132,6 +143,12 @@ public final class PlayerChunkLoader {
|
||||
|
||||
// no throttling is applied below this VD for loading
|
||||
|
||||
+ // Kaiiju start - Static distance
|
||||
+ public final PlayerAreaMap staticMap;
|
||||
+ protected int rawStaticDistance = -1;
|
||||
+ // Kaiiju end
|
||||
+
|
||||
+
|
||||
/**
|
||||
* The chunks to be sent to players, provided they're send-ready. Send-ready means the chunk and its 1 radius neighbours are loaded.
|
||||
*/
|
||||
@@ -190,6 +207,12 @@ public final class PlayerChunkLoader {
|
||||
return this.rawSendDistance == -1 ? this.getLoadDistance() : this.rawSendDistance;
|
||||
}
|
||||
|
||||
+ // Kaiiju start - Static distance
|
||||
+ public int getTargetStaticDistance() {
|
||||
+ return this.rawStaticDistance == -1 ? this.getStaticDistance() : this.rawStaticDistance;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
public void setTargetSendDistance(final int distance) {
|
||||
this.setSendDistance(distance);
|
||||
}
|
||||
@@ -231,6 +254,16 @@ public final class PlayerChunkLoader {
|
||||
this.rawTickDistance = distance;
|
||||
}
|
||||
|
||||
+ // Kaiiju start - Static distance
|
||||
+ public void setStaticDistance(final int distance) {
|
||||
+ this.rawStaticDistance = distance;
|
||||
+ }
|
||||
+
|
||||
+ public int getStaticDistance() {
|
||||
+ return this.rawStaticDistance;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
/*
|
||||
Players have 3 different types of view distance:
|
||||
1. Sending view distance
|
||||
@@ -256,7 +289,13 @@ public final class PlayerChunkLoader {
|
||||
|
||||
public PlayerChunkLoader(final ChunkMap chunkMap, final PooledLinkedHashSets<ServerPlayer> pooledHashSets) {
|
||||
this.chunkMap = chunkMap;
|
||||
+ // Kaiiju start - Static distance
|
||||
this.broadcastMap = new PlayerAreaMap(pooledHashSets,
|
||||
+ null,
|
||||
+ (ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
|
||||
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newState) -> {});
|
||||
+ // Kaiiju end
|
||||
+ this.staticMap = new PlayerAreaMap(pooledHashSets,
|
||||
null,
|
||||
(ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
|
||||
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newState) -> {
|
||||
@@ -807,6 +846,7 @@ public final class PlayerChunkLoader {
|
||||
protected int sendViewDistance = -1;
|
||||
protected int loadViewDistance = -1;
|
||||
protected int tickViewDistance = -1;
|
||||
+ protected int staticViewDistance = -1; // Kaiiju
|
||||
|
||||
protected long nextChunkSendTarget;
|
||||
|
||||
@@ -932,6 +972,7 @@ public final class PlayerChunkLoader {
|
||||
this.loader.loadMap.remove(this.player);
|
||||
this.loader.loadTicketCleanup.remove(this.player);
|
||||
this.loader.tickMap.remove(this.player);
|
||||
+ this.loader.staticMap.remove(this.player); // Kaiiju
|
||||
}
|
||||
|
||||
protected int getClientViewDistance() {
|
||||
Reference in New Issue
Block a user