Compare commits

...

70 Commits

Author SHA1 Message Date
Sofiane H. Djerbi
fe414e027b Cleaning 2023-05-17 02:48:11 +03:00
Sofiane H. Djerbi
ab7a79c7b7 Still apply effect with entityscheduler 2023-05-17 02:45:18 +03:00
Sofiane H. Djerbi
3044e2a70d Remove "Fix off thread raid winners": upstream fix 2023-05-17 02:09:20 +03:00
kugge
ee365adb62 Update Upstream (Folia) 2023-05-16 16:37:51 +02:00
Sofiane H. Djerbi
d78112453c Update upstream (Folia) 2023-05-15 23:05:22 +02:00
Sofiane H. Djerbi
42d7d8a151 Delete "Fix villagers forgetting their jobsites" 2023-05-15 23:05:22 +02:00
Sofiane H. Djerbi
f936afbdfd Update upstream 2023-05-15 23:05:22 +02:00
Sofiane H. Djerbi
e611832cb7 Kick player instead of crashing whole server 2023-05-15 23:05:22 +02:00
Sofiane H. Djerbi
62951f0d92 Fix villagers forgetting jobsites 2023-05-15 23:05:22 +02:00
Sofiane H. Djerbi
73ab029e4c Update README.md 2023-05-12 02:33:50 +03:00
Sofiane H. Djerbi
47b4ce394c Adding SIMD back after tests 2023-05-12 02:32:22 +03:00
Sofiane H. Djerbi
6275320901 Change the toggle from world to global config 2023-05-11 22:42:18 +03:00
Sofiane H. Djerbi
a113654b36 Move simd to todo 2023-05-11 22:15:40 +03:00
Sofiane H. Djerbi
671522acdc Moving simd utils 2023-05-11 17:32:57 +03:00
Sofiane H. Djerbi
2779390c6b Allow RNG manipulation for players 2023-05-11 17:12:52 +03:00
Sofiane H. Djerbi
4fc704f16a SIMD utilities 2023-05-11 05:20:56 +03:00
Sofiane H. Djerbi
423f48684a Fix #54 (Spider version) 2023-05-10 17:59:29 +03:00
Sofiane H. Djerbi
c027a2e37f Benchmarked optimization 2023-05-10 16:50:38 +03:00
Sofiane H. Djerbi
3ec9267550 Fix #54 2023-05-09 17:38:42 +03:00
Sofiane H. Djerbi
57bd665a5e Another change for vanilla parity 2023-05-07 20:09:26 +03:00
Sofiane H. Djerbi
5faba7039e Update README.md 2023-05-07 14:35:06 +03:00
Sofiane H. Djerbi
3d7011f7d7 Added timestamps to linear 2023-05-06 02:46:36 +03:00
Sofiane H. Djerbi
74d3638155 Should we tick level when empty 2023-05-05 02:13:57 +03:00
Sofiane H. Djerbi
2da29dfbc5 Merge branch 'ver/1.19.4' of github.com:KaiijuMC/Kaiiju into ver/1.19.4 2023-05-04 17:37:58 +03:00
Sofiane H. Djerbi
d422fc645c Drop that stuping patch name convention 2023-05-04 17:37:35 +03:00
kugge
53851e72d4 Update Upstream (Folia) 2023-05-02 18:40:07 +02:00
Sofiane H. Djerbi
7c618748c6 Update README.md 2023-05-01 15:39:46 +02:00
Sofiane H. Djerbi
f63cf7c1fa [ci skip] Update README.md 2023-04-28 03:26:18 +03:00
Sofiane H. Djerbi
ea9ab3f27c Add an option to trigger hopper optimization
This patch break random redstone farm
We want kaiiju to be as vanilla as possible
And to respect every end user
So here is a toggle.
2023-04-27 04:21:20 +03:00
Sofiane H. Djerbi
ae5526ff76 Add comment 2023-04-25 02:51:02 +03:00
Sofiane H. Djerbi
f6f2314be6 Add todo dir 2023-04-23 23:50:53 +03:00
kugge
4e5feda68f Update Upstream (Folia) 2023-04-23 23:11:01 +03:00
Sofiane H. Djerbi
b6729158b0 Add void trading fix 2023-04-23 15:53:27 +03:00
kugge
d4cd2cf5b3 Update Upstream (Folia) 2023-04-19 16:36:35 +03:00
kugge
c4741b284e Update Upstream (Folia) 2023-04-18 02:25:58 +03:00
github-actions[bot]
65ee54da34 Update Upstream (Folia) (#46) 2023-04-16 18:22:36 +03:00
Sofiane H. Djerbi
7ebfac20b8 [ci skip] Update README.md 2023-04-16 18:09:24 +03:00
Sofiane H. Djerbi
fa210d634d Update README.md 2023-04-16 16:35:30 +03:00
Sofiane H. Djerbi
91eaf9966d Cleaning up skipping code 2023-04-16 05:14:15 +03:00
Sofiane H. Djerbi
3bc1986806 Add back symlink verification on existingOnly 2023-04-16 04:41:22 +03:00
Sofiane H. Djerbi
3f3c9292bf Update gradle & dependencies 2023-04-16 03:46:55 +03:00
xymb-endcrystalme
6a994e5d50 Add an option to crash on broken Linear symlink (#45)
* Add an option to crash on broken Linear symlink

* Refactoring Crash on broken symlink

---------

Co-authored-by: Sofiane H. Djerbi <46628754+kugge@users.noreply.github.com>
2023-04-16 03:24:48 +03:00
Sofiane H. Djerbi
034cf1e6d6 Merge pull request #43 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-11 04:19:40 +03:00
kugge
118cabf45c Update Upstream (Folia) 2023-04-11 01:08:48 +00:00
Sofiane H. Djerbi
5562bd750f Merge pull request #42 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-11 02:17:39 +03:00
kugge
cedc442598 Update Upstream (Folia) 2023-04-10 23:07:20 +00:00
Sofiane H. Djerbi
35983edbd3 [skip ci] Quickfix uncommented line 2023-04-09 18:03:48 +03:00
Sofiane H. Djerbi
8664b137ca Merge pull request #40 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-09 17:38:44 +03:00
kugge
94d5a28cc4 Update Upstream (Folia) 2023-04-09 14:32:34 +00:00
Sofiane H. Djerbi
76890444db Adding Purpur custom server mod name 2023-04-09 17:17:26 +03:00
Sofiane H. Djerbi
08dd766899 Consistency fixes 2023-04-09 17:17:16 +03:00
Sofiane H. Djerbi
7fb8ff8fd0 Merge pull request #39 from xymb-endcrystalme/ver/1.19.4
Add option to drop contents of shulker items when destroyed.
2023-04-09 00:10:38 +03:00
Sofiane H. Djerbi
32e02629a9 Quickfix patching conventions
UPSTREAM-CATEGORY-OPTION (for future automation purposes)
Split configuration commits (tracking adding config options)
Use per world config if possible
2023-04-09 00:09:39 +03:00
Xymb
ef8af2f22a Add option to drop contents of shulker items when destroyed. 2023-04-08 18:48:31 +02:00
Xymb
23b264963e Ensure atomicity on Btrfs 2023-04-08 18:38:25 +02:00
Sofiane H. Djerbi
95e8ffed83 Merge pull request #36 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-04 09:52:38 +02:00
kugge
e2b32c0b66 Update Upstream (Folia) 2023-04-04 07:52:26 +00:00
Sofiane H. Djerbi
12d82f3aa5 Merge pull request #35 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-01 17:32:23 +02:00
kugge
e7b45be456 Update Upstream (Folia) 2023-04-01 15:10:51 +00:00
Sofiane H. Djerbi
48a3fc55b7 Merge pull request #34 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-01 15:53:23 +02:00
kugge
29b6a8d59d Update Upstream (Folia) 2023-04-01 13:14:40 +00:00
Sofiane H. Djerbi
f7a4bb691b Merge pull request #33 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-01 06:01:18 +02:00
kugge
34724b4471 Update Upstream (Folia) 2023-04-01 04:00:40 +00:00
Sofiane H. Djerbi
660e911bbb Merge pull request #32 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-01 05:38:52 +02:00
kugge
092e4ddbd8 Update Upstream (Folia) 2023-04-01 03:38:16 +00:00
Sofiane H. Djerbi
7fd3f17095 Update README.md 2023-04-01 03:32:09 +02:00
Sofiane H. Djerbi
53fdedd162 Merge pull request #31 from KaiijuMC/update-upstream
Update Upstream (Folia)
2023-04-01 03:29:09 +02:00
kugge
e0f78402c8 Update Upstream (Folia) 2023-04-01 01:28:30 +00:00
Sofiane H. Djerbi
d36d0dc5fc Sand duping need plugin 2023-04-01 04:22:05 +03:00
Sofiane H. Djerbi
f6246f3349 Dropped lithium support 2023-03-31 19:36:28 +03:00
34 changed files with 1503 additions and 704 deletions

View File

@@ -12,15 +12,47 @@
## Features
### Additions
- **Xymb Linear Format**: Saves about 50% of disk space in OW and Nether and 95% in The End.
- **Auto update**: Update upstream everyday.
### 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
region-format:
debug: false
network:
send-null-entity-packets: true
alternate-keepalive: false
gameplay:
server-mod-name: Kaiiju
shared-random-for-players: true
world-settings:
default:
region-format:
format: ANVIL
linear:
compression-level: 1
crash-on-broken-symlink: true
gameplay:
shulker-box-drop-contents-when-destroyed: true
fix-void-trading: true
optimize-hoppers: true
tick-when-empty: true
break-redstone-on-top-of-trap-doors-early: true
config-version: 1
```
Documentation: [Kaiiju Wiki](https://github.com/KaiijuMC/Kaiiju/wiki/Configuration)
### Roadmap
- **Static view distance**: Reduce RAM usage with a "cached" view distance.
- **Lithium**: Implementation of Lithium server mixins.
- **C2ME**: Implementation of C2ME server mixins.
- **VMP**: Implementation of VMP server mixins.
- **Static view distance**: Reduce RAM usage / Region size with a "static" view distance.
- **Native world conversion**: Convert region file format at startup.
- **Stash deduplication**: Make giant dupe stashes possible and lagless.
## Building
@@ -31,5 +63,3 @@
## License
Original patches are licensed under GPL-3.0.
Made with <span style="color: #e25555;">&#9829;</span> on Earth.

View File

@@ -3,8 +3,8 @@ import io.papermc.paperweight.util.constants.*
plugins {
java
id("com.github.johnrengelman.shadow") version "7.1.2"
id("io.papermc.paperweight.patcher") version "1.5.1"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.papermc.paperweight.patcher") version "1.5.4"
}
allprojects {
@@ -30,8 +30,8 @@ repositories {
dependencies {
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
paperclip("io.papermc:paperclip:3.0.2")
decompiler("net.minecraftforge:forgeflower:2.0.629.0")
paperclip("io.papermc:paperclip:3.0.3")
}
subprojects {
@@ -72,36 +72,35 @@ paperweight {
serverOutputDir.set(layout.projectDirectory.dir("kaiiju-server"))
}
}
}
tasks.register("foliaRefLatest") {
// Update the foliaRef in gradle.properties to be the latest commit.
val tempDir = layout.cacheDir("foliaRefLatest");
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 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;
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("foliaRef = .*".toRegex(), "foliaRef = $foliaLatestCommit")
}
}
}
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)
}
}
}

View File

@@ -2,7 +2,7 @@ group = dev.kaiijumc.kaiiju
version = 1.19.4-R0.1-SNAPSHOT
mcVersion = 1.19.4
foliaRef = ed7a5c57f4082107751dd8aad431d45ab5fab1d2
foliaRef = f15f1ceab565ce6af84cba2d41de32669e6c3bad
org.gradle.caching=true
org.gradle.parallel=true

Binary file not shown.

View File

@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.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
View File

@@ -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
View File

@@ -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

View 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: Tue, 9 May 2023 15:11:56 +0300
Subject: [PATCH] Fix off thread raid winners
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
index 359f1690497eac00899eb26c17308e0a6fe943ad..3cc320e854cbb9e70b6c63f1f950091c5195edae 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
@@ -404,6 +404,7 @@ public class Raid {
UUID uuid = (UUID) iterator.next();
Entity entity = this.level.getEntity(uuid);
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity)) continue; // Kaiiju - Prevent give effect to player off thread
if (entity instanceof LivingEntity && !entity.isSpectator()) {
LivingEntity entityliving = (LivingEntity) entity;

View File

@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Fri, 10 Feb 2023 02:58:46 +0200
Subject: [PATCH] Kaiiju Rebranding
Subject: [PATCH] Rebranding
diff --git a/build.gradle.kts b/build.gradle.kts
@@ -48,7 +48,7 @@ index 58dc84b7b3b04c2d0b00fc5fac5303d3378b3467..a128b1fabd4aadfe26a8375903c0451d
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 719b0e318a85d4a1fb8f616deeb31193495b462e..751b2bc79d29cb21c38cf5d35e3711149ec7b011 100644
index 2ce29b6ccb9a3b520b8c1edf53aae2e9769ba252..f675fcae235a8c2722d9bba65d5e1292c5b76deb 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
@@ -19,10 +19,11 @@ import java.util.stream.StreamSupport;

View File

@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Fri, 10 Feb 2023 05:53:10 +0200
Subject: [PATCH] Kaiiju Configuration
Subject: [PATCH] Empty configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -432,7 +432,7 @@ index 7abd4f38ae59a6019137345af960fd60a3c7adf0..426777730f77664c69bd0a084a9323d7
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 c7c682cd2d1498e6d6521ddd62acdc1168bfe152..53b9444ff6120628d23ad27fc87d9cd9bdf66648 100644
index afb3d0fa48b7fd6d273361c6dc32764b5d35c356..a3b4b49ca8612a61bc2e7a1e2d2e942e7ebe1883 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -167,6 +167,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -453,7 +453,7 @@ index c7c682cd2d1498e6d6521ddd62acdc1168bfe152..53b9444ff6120628d23ad27fc87d9cd9
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 b1680507c05547458e1199412ab97105b67f8973..d1468cb0ae1850719d40524dad9b14fbdb0f79a1 100644
index 176f3acec268dad80cc90029edd88e7a0c3e8885..48f946243af24a9d4847f6a7a59449136cf6ee83 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1067,6 +1067,7 @@ public final class CraftServer implements Server {

View File

@@ -1,16 +1,16 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Fri, 10 Feb 2023 20:03:58 +0200
Subject: [PATCH] Kaiiju RegionFormat Configuration
Subject: [PATCH] Region format configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 75f9fc471069507168ad23092bc77e0d1597fd1d..6af036b2d11aa74bb4a371c03bd2e637f49ed166 100644
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..b86c90cc3601e666998cfa12f44515f605bb53eb 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -195,4 +195,10 @@ public class KaiijuConfig {
private static void exploitSettings() {
@@ -192,4 +192,10 @@ public class KaiijuConfig {
}
return builder.build();
}
+
+ public static boolean regionFormatDebug = false;
@@ -20,7 +20,7 @@ index 75f9fc471069507168ad23092bc77e0d1597fd1d..6af036b2d11aa74bb4a371c03bd2e637
+ }
}
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 410bb2832140648ab0b59a35545a27f7d78c7222..421d21d3f1126101e66d54894a39b657de7d1590 100644
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;
@@ -35,9 +35,9 @@ index 410bb2832140648ab0b59a35545a27f7d78c7222..421d21d3f1126101e66d54894a39b657
import static dev.kaiijumc.kaiiju.KaiijuConfig.log;
@@ -128,4 +130,23 @@ public class KaiijuWorldConfig {
private void exploitSettings() {
fixSandDuping = getBoolean("exploit.fix-sand-duping", fixSandDuping);
@@ -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");

View File

@@ -1,11 +1,12 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Fri, 10 Feb 2023 22:21:56 +0200
Subject: [PATCH] Kaiiju RegionFormat Linear
Subject: [PATCH] Add Linear region format
Linear is a region file format that uses ZSTD compression instead of
ZLIB.
This format saves about 50% of disk space.
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 6dd416f65755ca0542e6661b8716672264120d59..4686019a152114e63e997ee103fc8424b24b4581 100644
@@ -111,10 +112,10 @@ index 0000000000000000000000000000000000000000..dcfbabf54b19a4c29d5c95830242c5c2
+}
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..f05d6313012560c32a3ec574b7169ec8e8930282
index 0000000000000000000000000000000000000000..b7ce89429675bde7f037793305275f4bf89d0727
--- /dev/null
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
@@ -0,0 +1,334 @@
@@ -0,0 +1,337 @@
+package dev.kaiijumc.kaiiju.region;
+
+import com.github.luben.zstd.ZstdInputStream;
@@ -123,7 +124,6 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+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;
@@ -136,15 +136,28 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class LinearRegionFile extends Thread implements AbstractRegionFile {
+ private static final long SUPERBLOCK = -4323716122432332390L;
+ private static final byte VERSION = 2;
+ private static final int HEADER_SIZE = 32;
+ private static final 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 static final List<Byte> SUPPORTED_VERSIONS = Arrays.asList((byte) 1, (byte) 2);
+
+
+ private final byte[][] buffer = new byte[1024][];
+ private final int[] bufferUncompressedSize = new int[1024];
+
+ private final int[] chunkTimestamps = new int[1024];
+ private final Object markedToSaveLock = new Object();
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
+ private final ChunkStatus[] statuses = new ChunkStatus[1024];
+
+ private final LZ4Compressor compressor;
+ private final LZ4FastDecompressor decompressor;
+
+ private boolean markedToSave = false;
+ private boolean close = false;
@@ -165,69 +178,60 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ 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)
+ throw new RuntimeException("Superblock invalid: " + superBlock + " file " + file);
+ throw new RuntimeException("Invalid superblock: " + superBlock + " file " + file);
+
+ byte version = rawDataStream.readByte();
+ if (!SUPPORTED_VERSIONS.contains(version))
+ throw new RuntimeException("Invalid version: " + version + " file " + file);
+
+ if (version != VERSION)
+ throw new RuntimeException("Version invalid: " + version + " file " + file);
+ // 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));
+ throw new IOException("Invalid file length: " + this.regionFile + " " + fileLength + " " + (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): Unused.
+ }
+
+ 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);
+
@@ -267,9 +271,7 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ }
+ for(int i = 0 ; i < 100 ; i++) {
+ Thread.sleep(100);
+ if(close) {
+ return;
+ }
+ if(close) return;
+ }
+ }
+ } catch(InterruptedException ignored) {}
@@ -280,12 +282,9 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ }
+
+ public synchronized void flush() throws IOException {
+ if(!isMarkedToSave())
+ return;
+ if(!isMarkedToSave()) return;
+
+ long SUPERBLOCK = -4323716122432332390L;
+ byte VERSION = 1;
+ long timestamp = System.currentTimeMillis() / 1000L;
+ long timestamp = getTimestamp();
+ short chunkCount = 0;
+
+ File tempFile = new File(regionFile.toString() + ".tmp");
@@ -302,23 +301,21 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ dataStream.writeLong(timestamp);
+ dataStream.writeByte(this.compressionLevel);
+
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
+
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
+ for(int i = 0 ; i < 32 * 32 ; i++) {
+ 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++) {
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]);
+ zstdDataStream.writeInt(0);
+ for(int i = 0; i < 1024; i++) {
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]); // Write uncompressed size
+ zstdDataStream.writeInt(this.chunkTimestamps[i]); // Write timestamp
+ }
+ 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);
+ }
@@ -329,11 +326,14 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ 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();
@@ -345,23 +345,23 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ }
+
+ 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;
+ int index = getChunkIndex(pos.x, pos.z);
+ this.buffer[index] = b;
+ this.chunkTimestamps[index] = getTimestamp();
+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize;
+ } catch (IOException e) {
+ LOGGER.error("Chunk write IOException " + e + " " + this.regionFile);
+ }
+
+ markToSave();
+ }
+
@@ -399,9 +399,8 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ @Nullable
+ 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;
@@ -415,6 +414,7 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ int i = getChunkIndex(pos.x, pos.z);
+ this.buffer[i] = null;
+ this.bufferUncompressedSize[i] = 0;
+ this.chunkTimestamps[i] = getTimestamp();
+ markToSave();
+ }
+
@@ -432,7 +432,11 @@ index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8
+ }
+
+ private static int getChunkIndex(int x, int z) {
+ return (x & 31) + (z & 31) * 32;
+ return (x & 31) + ((z & 31) << 5);
+ }
+
+ private static int getTimestamp() {
+ return (int) (System.currentTimeMillis() / 1000L);
+ }
+
+ public boolean recalculateHeader() {
@@ -537,7 +541,7 @@ index 513833c2ea23df5b079d157bc5cb89d5c9754c0b..a62a1b281bd0b6ad7d59b45b9470d84f
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 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d640725dc0 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
@@ -272,7 +272,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -558,7 +562,7 @@ index 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d6
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);
@@ -849,13 +849,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -853,13 +853,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper start - chunk status cache "api"
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
@@ -574,7 +578,7 @@ index 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d6
if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
return null;
@@ -873,7 +873,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 {

View File

@@ -1,43 +0,0 @@
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:21:52 +0300
Subject: [PATCH] Purpur Exploit Toggleable Sand Duping
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 0555d436e38c388578e563a9120ebfe5334ae2c2..410bb2832140648ab0b59a35545a27f7d78c7222 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -123,6 +123,9 @@ public class KaiijuWorldConfig {
return value.isEmpty() ? fallback : value;
}
+ public boolean fixSandDuping = true;
+
private void exploitSettings() {
+ fixSandDuping = getBoolean("exploit.fix-sand-duping", fixSandDuping);
}
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index c8d125955754e27da54d95fb5b1cea39ca54b618..f0a15acb604bb636bd49c0ce931053541986797d 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -131,7 +131,7 @@ public class FallingBlockEntity extends Entity {
@Override
public void tick() {
// Paper start - fix sand duping
- if (this.isRemoved()) {
+ if (this.level.kaiijuConfig.fixSandDuping && this.isRemoved()) { // Kaiiju
return;
}
// Paper end - fix sand duping
@@ -148,7 +148,7 @@ public class FallingBlockEntity extends Entity {
this.move(MoverType.SELF, this.getDeltaMovement());
// Paper start - fix sand duping
- if (this.isRemoved()) {
+ if (this.level.kaiijuConfig.fixSandDuping && this.isRemoved()) { // Kaiiju
return;
}
// Paper end - fix sand duping

View File

@@ -1,14 +1,14 @@
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
Subject: [PATCH] Network configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 6af036b2d11aa74bb4a371c03bd2e637f49ed166..8e7892cb46385ba3189485c144ec9fbcdc347502 100644
index b86c90cc3601e666998cfa12f44515f605bb53eb..7c6d43d8a360530344ef296f4477750c8a298607 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -201,4 +201,7 @@ public class KaiijuConfig {
@@ -198,4 +198,7 @@ public class KaiijuConfig {
private static void regionFormatSettings() {
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
}

View File

@@ -1,14 +1,15 @@
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 Send Null Entity Packets
Subject: [PATCH] Send null entity packets
This is from Purpur. Don't send null entity packets.
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 8e7892cb46385ba3189485c144ec9fbcdc347502..94a033e835915dc84c0dd4a84d218c0283aa03fe 100644
index 7c6d43d8a360530344ef296f4477750c8a298607..ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -201,7 +201,10 @@ public class KaiijuConfig {
@@ -198,7 +198,10 @@ public class KaiijuConfig {
private static void regionFormatSettings() {
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
}

View File

@@ -1,14 +1,16 @@
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 Alternate Keepalive
Subject: [PATCH] Alternate Keepalive
Don't kick players because 1 keepalive is lost.
This patch is from Purpur.
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 94a033e835915dc84c0dd4a84d218c0283aa03fe..e88e9197e99ac68fd58d48e7722eb6254ee75388 100644
index ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7..b42a3466f145a92608c8746fd4beb529b4a60b01 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -203,8 +203,10 @@ public class KaiijuConfig {
@@ -200,8 +200,10 @@ public class KaiijuConfig {
}
public static boolean sendNullEntityPackets = true;
@@ -16,11 +18,11 @@ index 94a033e835915dc84c0dd4a84d218c0283aa03fe..e88e9197e99ac68fd58d48e7722eb625
private static void networkSettings() {
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
+ alternateKeepAlive = getBoolean("network.alternate-keepalive", 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 96203bd4d7af425236db220b746a9dcba38bfd08..40af4162787e03af9842d661835de806c71e6204 100644
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
@@ -52,7 +54,7 @@ index 96203bd4d7af425236db220b746a9dcba38bfd08..40af4162787e03af9842d661835de806
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
@@ -3517,6 +3532,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3534,6 +3549,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@Override
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {

View File

@@ -1,31 +1,31 @@
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:13:35 +0300
Subject: [PATCH] Kaiiju Exploit Configuration
Date: Sat, 8 Apr 2023 23:32:34 +0300
Subject: [PATCH] Gameplay Configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..75f9fc471069507168ad23092bc77e0d1597fd1d 100644
index b42a3466f145a92608c8746fd4beb529b4a60b01..6d0e1edfb7d3c020f70f6a194f16e836b462c4de 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -192,4 +192,7 @@ public class KaiijuConfig {
}
return builder.build();
@@ -206,4 +206,7 @@ public class KaiijuConfig {
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
}
+
+ private static void exploitSettings() {
+ 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 dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..0555d436e38c388578e563a9120ebfe5334ae2c2 100644
index b194f4dbebcbbf5bb4e026a0169e2d24806b46ec..73d79fe0077b28db2f9e7fa13a1ae6eff9abd6a9 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;
@@ -143,4 +143,7 @@ public class KaiijuWorldConfig {
regionFormatLinearCompressionLevel = 1;
}
}
+
+ private void exploitSettings() {
+ private void gameplaySettings() {
+ }
}
\ No newline at end of file

View File

@@ -0,0 +1,36 @@
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] Shulker drop contents when destroyed
Don't drop shulker contents when shulker items are destroyed (by cactus,
lava..)
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);

View File

@@ -1,20 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Thu, 16 Feb 2023 21:28:49 +0200
Subject: [PATCH] Kaiiju Lithium Configuration
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index e88e9197e99ac68fd58d48e7722eb6254ee75388..4c9200e51ffc24b354d83822b78526d853ad4ddc 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -209,4 +209,9 @@ public class KaiijuConfig {
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
alternateKeepAlive = getBoolean("network.alternate-keepalive", sendNullEntityPackets);
}
+
+ public static boolean lithiumEnable = true;
+ private static void lithiumSettings() {
+ lithiumEnable = getBoolean("lithium.enable", lithiumEnable);
+ }
}

View 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] Server mod name
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) {

View 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] Crash on broken symlink
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 5ad209fed6aef1992af0472ac0af0911d178a260..0ef89e0bc214364fd904c3e5022c660b32b2caaa 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;

View File

@@ -1,125 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Thu, 16 Feb 2023 21:34:37 +0200
Subject: [PATCH] Lithium Math FastUtil
Author: JellySquid
Licence: LGPL-3.0
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 4c9200e51ffc24b354d83822b78526d853ad4ddc..48bf2e11a4d869aeef4ce7169636ff625555f7e1 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -211,7 +211,9 @@ public class KaiijuConfig {
}
public static boolean lithiumEnable = true;
+ public static boolean lithiumMathFastUtil = true;
private static void lithiumSettings() {
lithiumEnable = getBoolean("lithium.enable", lithiumEnable);
+ lithiumMathFastUtil = getBoolean("lithium.math.fast-util", lithiumMathFastUtil) && lithiumEnable;
}
}
diff --git a/src/main/java/net/minecraft/core/AxisCycle.java b/src/main/java/net/minecraft/core/AxisCycle.java
index b5d8a60dc78a76c0a55bfc30cc49d26857bd914a..dd8d98acf21bb676e86f9befb45fd09e1b14a01d 100644
--- a/src/main/java/net/minecraft/core/AxisCycle.java
+++ b/src/main/java/net/minecraft/core/AxisCycle.java
@@ -35,6 +35,18 @@ public enum AxisCycle {
@Override
public Direction.Axis cycle(Direction.Axis axis) {
+ // Kaiiju start - Lithium
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil){
+ switch (axis.ordinal()) {
+ case 0: //X
+ return Direction.Axis.Y;
+ case 1: //Y
+ return Direction.Axis.Z;
+ case 2: //Z
+ return Direction.Axis.X;
+ }
+ }
+ // Kaiiju end
return AXIS_VALUES[Math.floorMod(axis.ordinal() + 1, 3)];
}
@@ -56,6 +68,18 @@ public enum AxisCycle {
@Override
public Direction.Axis cycle(Direction.Axis axis) {
+ // Kaiiju start - Lithium
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil){
+ switch (axis.ordinal()) {
+ case 0: //X
+ return Direction.Axis.Z;
+ case 1: //Y
+ return Direction.Axis.X;
+ case 2: //Z
+ return Direction.Axis.Y;
+ }
+ }
+ // Kaiiju end
return AXIS_VALUES[Math.floorMod(axis.ordinal() - 1, 3)];
}
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
index 82bce6109d59cba30178a446f0ff129da6f3692f..597e5c3e25190d61b9b3c1198bd668083dfc2f0d 100644
--- a/src/main/java/net/minecraft/core/Direction.java
+++ b/src/main/java/net/minecraft/core/Direction.java
@@ -192,6 +192,7 @@ public enum Direction implements StringRepresentable {
}
public Direction getOpposite() {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil) return VALUES[this.oppositeIndex]; // Kaiiju
return from3DDataValue(this.oppositeIndex);
}
@@ -442,6 +443,7 @@ public enum Direction implements StringRepresentable {
}
public static Direction getRandom(RandomSource random) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil) return VALUES[random.nextInt(VALUES.length)]; // Kaiiju
return Util.getRandom(VALUES, random);
}
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
index ffc76354ead6937daf366c3d87bcb51d3e4c47f5..07965ebef2326c73f94a97f478ba1fd0d1ed5dce 100644
--- a/src/main/java/net/minecraft/world/phys/AABB.java
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
@@ -81,10 +81,36 @@ public class AABB {
}
public double min(Direction.Axis axis) {
+ // Kaiiju start - Lithium
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil){
+ switch (axis.ordinal()) {
+ case 0: //X
+ return this.minX;
+ case 1: //Y
+ return this.minY;
+ case 2: //Z
+ return this.minZ;
+ }
+ throw new IllegalArgumentException();
+ }
+ // Kaiiju end
return axis.choose(this.minX, this.minY, this.minZ);
}
public double max(Direction.Axis axis) {
+ // Kaiiju start - Lithium
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil){
+ switch (axis.ordinal()) {
+ case 0: //X
+ return this.maxX;
+ case 1: //Y
+ return this.maxY;
+ case 2: //Z
+ return this.maxZ;
+ }
+ throw new IllegalArgumentException();
+ }
+ // Kaiiju end
return axis.choose(this.maxX, this.maxY, this.maxZ);
}

View File

@@ -1,149 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Fri, 17 Feb 2023 00:34:31 +0200
Subject: [PATCH] Lithium Math SineLut
Author: JellySquid
Licence: LGPL-3.0
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 48bf2e11a4d869aeef4ce7169636ff625555f7e1..46389c9cbc00ffa0303886cd6cba7df94777e0f1 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -212,8 +212,10 @@ public class KaiijuConfig {
public static boolean lithiumEnable = true;
public static boolean lithiumMathFastUtil = true;
+ public static boolean lithiumMathSineLut = true;
private static void lithiumSettings() {
lithiumEnable = getBoolean("lithium.enable", lithiumEnable);
lithiumMathFastUtil = getBoolean("lithium.math.fast-util", lithiumMathFastUtil) && lithiumEnable;
+ lithiumMathSineLut = getBoolean("lithium.math.sine-lut", lithiumMathSineLut) && lithiumEnable;
}
}
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java b/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java
new file mode 100644
index 0000000000000000000000000000000000000000..ccb45e94ea6d1a627df786fb88baec7edd1f2427
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java
@@ -0,0 +1,90 @@
+package me.jellysquid.mods.lithium.common.util.math;
+
+import net.minecraft.util.Mth;
+
+/**
+ * A replacement for the sine angle lookup table used in {@link MathHelper}, both reducing the size of LUT and improving
+ * the access patterns for common paired sin/cos operations.
+ *
+ * sin(-x) = -sin(x)
+ * ... to eliminate negative angles from the LUT.
+ *
+ * sin(x) = sin(pi/2 - x)
+ * ... to eliminate supplementary angles from the LUT.
+ *
+ * Using these identities allows us to reduce the LUT from 64K entries (256 KB) to just 16K entries (64 KB), enabling
+ * it to better fit into the CPU's caches at the expense of some cycles on the fast path. The implementation has been
+ * tightly optimized to avoid branching where possible and to use very quick integer operations.
+ *
+ * Generally speaking, reducing the size of a lookup table is always a good optimization, but since we need to spend
+ * extra CPU cycles trying to maintain parity with vanilla, there is the potential risk that this implementation ends
+ * up being slower than vanilla when the lookup table is able to be kept in cache memory.
+ *
+ * Unlike other "fast math" implementations, the values returned by this class are *bit-for-bit identical* with those
+ * from {@link MathHelper}. Validation is performed during runtime to ensure that the table is correct.
+ *
+ * @author coderbot16 Author of the original (and very clever) implementation in Rust:
+ * https://gitlab.com/coderbot16/i73/-/tree/master/i73-trig/src
+ * @author jellysquid3 Additional optimizations, port to Java
+ */
+public class CompactSineLUT {
+ private static final int[] SINE_TABLE_INT = new int[16384 + 1];
+ private static final float SINE_TABLE_MIDPOINT;
+
+ static {
+ final float[] SINE_TABLE = Mth.getSinTable();
+ // Copy the sine table, covering to raw int bits
+ for (int i = 0; i < SINE_TABLE_INT.length; i++) {
+ SINE_TABLE_INT[i] = Float.floatToRawIntBits(SINE_TABLE[i]);
+ }
+
+ SINE_TABLE_MIDPOINT = SINE_TABLE[SINE_TABLE.length / 2];
+
+ // Test that the lookup table is correct during runtime
+ for (int i = 0; i < SINE_TABLE.length; i++) {
+ float expected = SINE_TABLE[i];
+ float value = lookup(i);
+
+ if (expected != value) {
+ throw new IllegalArgumentException(String.format("LUT error at index %d (expected: %s, found: %s)", i, expected, value));
+ }
+ }
+ }
+
+ // [VanillaCopy] MathHelper#sin(float)
+ public static float sin(float f) {
+ return lookup((int) (f * 10430.378f) & 0xFFFF);
+ }
+
+ // [VanillaCopy] MathHelper#cos(float)
+ public static float cos(float f) {
+ return lookup((int) (f * 10430.378f + 16384.0f) & 0xFFFF);
+ }
+
+ private static float lookup(int index) {
+ // A special case... Is there some way to eliminate this?
+ if (index == 32768) {
+ return SINE_TABLE_MIDPOINT;
+ }
+
+ // Trigonometric identity: sin(-x) = -sin(x)
+ // Given a domain of 0 <= x <= 2*pi, just negate the value if x > pi.
+ // This allows the sin table size to be halved.
+ int neg = (index & 0x8000) << 16;
+
+ // All bits set if (pi/2 <= x), none set otherwise
+ // Extracts the 15th bit from 'half'
+ int mask = (index << 17) >> 31;
+
+ // Trigonometric identity: sin(x) = sin(pi/2 - x)
+ int pos = (0x8001 & mask) + (index ^ mask);
+
+ // Wrap the position in the table. Moving this down to immediately before the array access
+ // seems to help the Hotspot compiler optimize the bit math better.
+ pos &= 0x7fff;
+
+ // Fetch the corresponding value from the LUT and invert the sign bit as needed
+ // This directly manipulate the sign bit on the float bits to simplify logic
+ return Float.intBitsToFloat(SINE_TABLE_INT[pos] ^ neg);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
index a378a2ddd96e76925fa3409282d9606a86c72334..19531bb7e37d13bdffd43aebb6de105268119d2d 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -38,11 +38,24 @@ public class Mth {
private static final double[] ASIN_TAB = new double[257];
private static final double[] COS_TAB = new double[257];
+ public static float truncate(float value, float digits) {
+ float f = (float)Math.pow(10.0D, (double)digits);
+ return (float)((int)(value * f)) / f;
+ }
+
+ // Kaiiju start
+ public static float[] getSinTable() {
+ return SIN;
+ }
+ // Kaiiju end
+
public static float sin(float value) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathSineLut) return me.jellysquid.mods.lithium.common.util.math.CompactSineLUT.sin(value); // Kaiiju
return SIN[(int)(value * 10430.378F) & '\uffff'];
}
public static float cos(float value) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathSineLut) return me.jellysquid.mods.lithium.common.util.math.CompactSineLUT.cos(value); // Kaiiju
return SIN[(int)(value * 10430.378F + 16384.0F) & '\uffff'];
}

View File

@@ -0,0 +1,38 @@
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] Toggle void trading
Don't close trading windows when the villager is unloaded.
You should set chunk-unloads to 0s in paper config file to enable void
trading. Or use Kaiivoid plugin.
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

View File

@@ -1,102 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kugge <sofiane.djerbi38@gmail.com>
Date: Fri, 17 Feb 2023 19:43:55 +0100
Subject: [PATCH] Lithium Entity FastRetrieval
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 46389c9cbc00ffa0303886cd6cba7df94777e0f1..8392dd45c0cfd13f3a1d4f3aeedb23b699eed8f9 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -213,9 +213,11 @@ public class KaiijuConfig {
public static boolean lithiumEnable = true;
public static boolean lithiumMathFastUtil = true;
public static boolean lithiumMathSineLut = true;
+ public static boolean lithiumEntityFastRetrieval = true;
private static void lithiumSettings() {
lithiumEnable = getBoolean("lithium.enable", lithiumEnable);
lithiumMathFastUtil = getBoolean("lithium.math.fast-util", lithiumMathFastUtil) && lithiumEnable;
lithiumMathSineLut = getBoolean("lithium.math.sine-lut", lithiumMathSineLut) && lithiumEnable;
+ lithiumEntityFastRetrieval = getBoolean("lithium.entity.fast-retrieval", lithiumEntityFastRetrieval) && lithiumEnable;
}
}
diff --git a/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java b/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
index ee692b49c62f36287bf9d008861f5d47e0e42c00..e2f0aefb59864ef88cce22dde33f8a72a18fe829 100644
--- a/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
+++ b/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
@@ -41,6 +41,43 @@ public class EntitySectionStorage<T extends EntityAccess> {
int n = SectionPos.posToSectionCoord(box.maxY + 0.0D);
int o = SectionPos.posToSectionCoord(box.maxZ + 2.0D);
+ // Kaiiju start
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumEntityFastRetrieval) {
+ if (m >= j + 4 || o >= l + 4) {
+ // Vanilla is likely more optimized when shooting entities with TNT cannons over huge distances.
+ // Choosing a cutoff of 4 chunk size, as it becomes more likely that these entity sections do not exist when
+ // they are far away from the shot entity (player despawn range, position maybe not on the ground, etc.)
+ this.forEachAccessibleNonEmptySectionVanilla(j, k, l, m, n, o, consumer);
+ } else {
+ // Vanilla order of the AVL long set is sorting by ascending long value. The x, y, z positions are packed into
+ // a long with the x position's lowest 22 bits placed at the MSB.
+ // Therefore, the long is negative iff the 22nd bit of the x position is set, which happens iff the x position
+ // is negative. A positive x position will never have its 22nd bit set, as these big coordinates are far outside
+ // the world. y and z positions are treated as unsigned when sorting by ascending long value, as their sign bits
+ // are placed somewhere inside the packed long
+ for (int x = j; x <= m; x++) {
+ for (int z = Math.max(l, 0); z <= o; z++) {
+ if (this.forEachInColumn(x, k, n, z, consumer).shouldAbort()) {
+ this.forEachAccessibleNonEmptySectionVanilla(j, k, l, m, n, o, consumer);
+ return;
+ }
+ }
+ int bound = Math.min(-1, o);
+ for (int z = l; z <= bound; z++) {
+ if (this.forEachInColumn(x, k, n, z, consumer).shouldAbort()) {
+ this.forEachAccessibleNonEmptySectionVanilla(j, k, l, m, n, o, consumer);
+ return;
+ }
+ }
+ }
+ }
+ } else {
+ this.forEachAccessibleNonEmptySectionVanilla(j, k, l, m, n, o, consumer);
+ }
+ }
+
+ private void forEachAccessibleNonEmptySectionVanilla(int j, int k, int l, int n, int m, int o, AbortableIterationConsumer<EntitySection<T>> consumer) {
+ // Kaiiju end
for(int p = j; p <= m; ++p) {
long q = SectionPos.asLong(p, 0, 0);
long r = SectionPos.asLong(p, -1, -1);
@@ -60,6 +97,31 @@ public class EntitySectionStorage<T extends EntityAccess> {
}
}
+ // Kaiiju start
+ private AbortableIterationConsumer.Continuation forEachInColumn(int x, int k, int n, int z, AbortableIterationConsumer<EntitySection<T>> action) {
+ AbortableIterationConsumer.Continuation ret = AbortableIterationConsumer.Continuation.CONTINUE;
+ //y from negative to positive, but y is treated as unsigned
+ for (int y = Math.max(k, 0); y <= n; y++) {
+ if ((ret = this.consumeSection(SectionPos.asLong(x, y, z), action)).shouldAbort()) {
+ return ret;
+ }
+ }
+ int bound = Math.min(-1, n);
+ for (int y = k; y <= bound; y++) {
+ if ((ret = this.consumeSection(SectionPos.asLong(x, y, z), action)).shouldAbort()) {
+ return ret;
+ }
+ }
+ return ret;
+ }
+ private AbortableIterationConsumer.Continuation consumeSection(long pos, AbortableIterationConsumer<EntitySection<T>> action) {
+ EntitySection<T> entitySection = this.getSection(pos);
+ if (entitySection != null && 0 != entitySection.size() && entitySection.getStatus().isAccessible()) {
+ return action.accept(entitySection);
+ }
+ return AbortableIterationConsumer.Continuation.CONTINUE;
+ }
+ // Kaiiju end
public LongStream getExistingSectionPositionsInChunk(long chunkPos) {
int i = ChunkPos.getX(chunkPos);

View File

@@ -0,0 +1,220 @@
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] Toggle optimize hoppers
Paper optimize hoppers patch break a lot of technical redstone farms because of piston updates. (Example: twiti888 wood farm)
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;

View File

@@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Thu, 4 May 2023 19:53:33 +0300
Subject: [PATCH] Toggle tick level when empty
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 2624e074e0a14f5e05aca8fa910b5e5d71f320a9..b674bad0ace0aba53f1f3e76e6c891421aaac2a5 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -149,10 +149,12 @@ public class KaiijuWorldConfig {
public boolean shulkerBoxDropContentsWhenDestroyed = true;
public boolean fixVoidTrading = true;
public boolean optimizeHoppers = true;
+ public boolean tickWhenEmpty = 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);
+ tickWhenEmpty = getBoolean("gameplay.tick-when-empty", tickWhenEmpty);
}
}
\ 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 92cc38353d25f3749186dbc062402c9bafb25fca..2fcd607c8200ca88e8f56cbe26c275915d3bc74d 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -743,7 +743,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
timings.doSounds.stopTiming(); // Spigot
regionizedWorldData.setHandlingTick(false); // Folia - regionised ticking
gameprofilerfiller.pop();
- boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
+ boolean flag = kaiijuConfig.tickWhenEmpty || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players // Kaiiju - i don't think so
if (flag) {
this.resetEmptyTime();

View File

@@ -0,0 +1,46 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Sun, 7 May 2023 20:04:06 +0300
Subject: [PATCH] Toggle break redstone on top of trap doors early
That patch break vanilla mechanics such as portal slicing.
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index b674bad0ace0aba53f1f3e76e6c891421aaac2a5..43c8e95454cfe831f69858eb3b520f9958280b54 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -150,11 +150,13 @@ public class KaiijuWorldConfig {
public boolean fixVoidTrading = true;
public boolean optimizeHoppers = true;
public boolean tickWhenEmpty = true;
+ public boolean breakRedstoneOnTopOfTrapDoorsEarly = 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);
tickWhenEmpty = getBoolean("gameplay.tick-when-empty", tickWhenEmpty);
+ breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
}
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java b/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java
index 4bddb91e289bbfbc75d532e63f935d585e41fc43..f8dba24931bcfa28bde9cdec0201b591f29f9e09 100644
--- a/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java
@@ -126,6 +126,7 @@ public class TrapDoorBlock extends HorizontalDirectionalBlock implements SimpleW
}
// CraftBukkit end
boolean open = (Boolean) state.getValue(TrapDoorBlock.OPEN) != flag1; // Folia - break redstone on trapdoors early
+ if (world.kaiijuConfig.breakRedstoneOnTopOfTrapDoorsEarly) { // Kaiiju - trigger break redstone on trapdoors early
// Folia start - break redstone on trapdoors early
// note: this must run before any state for this block/its neighborus are written to the world
// we allow the redstone event to fire so that plugins can block
@@ -144,6 +145,7 @@ public class TrapDoorBlock extends HorizontalDirectionalBlock implements SimpleW
}
}
// Folia end - break redstone on trapdoors early
+ } // Kaiiju - trigger break redstone on trapdoors early
if (open) { // Folia - break redstone on trapdoors early
state = (BlockState) state.setValue(TrapDoorBlock.OPEN, flag1);
this.playSound((Player) null, world, pos, flag1);

View File

@@ -0,0 +1,139 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Wed, 10 May 2023 16:30:38 +0300
Subject: [PATCH] Strip raytracing for EntityLiving#hasLineOfSight
This has been benchmarked on a huge gold farm.
Resulting in significative performance improvements.
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 49716190b784339b80c8a3ac8e5b13bc450284ee..440735caab3be903546638a3d01903720225c553 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3612,7 +3612,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
// Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists
- return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; // Paper - use distanceToSqr
+ return !(vec3d1.distanceToSqr(vec3d) > 128D * 128D) && this.level.rayTraceDirect(vec3d, vec3d1, net.minecraft.world.phys.shapes.CollisionContext.of(this)) == net.minecraft.world.phys.BlockHitResult.Type.MISS; // Paper - use distanceToSqr // Kaiiju - Pufferfish - Strip raytracing
}
}
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
index 2ee9e8e3c1a28c1823de8e1fe421cc1f3e72f384..d99d77536e4d49b53575ae30614c0ab5fdbd3f73 100644
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
@@ -73,6 +73,17 @@ public interface BlockGetter extends LevelHeightAccessor {
});
}
+ // Kaiiju start - Pufferfish - broken down variant of below rayTraceBlock, used by World#rayTraceDirect
+ @Nullable
+ default net.minecraft.world.phys.BlockHitResult.Type rayTraceBlockDirect(Vec3 vec3d, Vec3 vec3d1, BlockPos blockposition, BlockState iblockdata, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) {
+ if (iblockdata.isAir()) return null;
+ VoxelShape voxelshape = ClipContext.Block.COLLIDER.get(iblockdata, this, blockposition, voxelshapecoll);
+ net.minecraft.world.phys.BlockHitResult movingobjectpositionblock = this.clipWithInteractionOverride(vec3d, vec3d1, blockposition, voxelshape, iblockdata);
+
+ return movingobjectpositionblock == null ? null : movingobjectpositionblock.getType();
+ }
+ // Kaiiju end
+
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
// Paper start - Prevent raytrace from loading chunks
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a3b4b49ca8612a61bc2e7a1e2d2e942e7ebe1883..933373aaa7b1fa07862e2146e079abe91d126263 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -433,6 +433,91 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return null;
}
+ // Kaiiju start - Pufferfish - broken down method of raytracing for EntityLiving#hasLineOfSight, replaces IBlockAccess#rayTrace(RayTrace)
+ public net.minecraft.world.phys.BlockHitResult.Type rayTraceDirect(net.minecraft.world.phys.Vec3 vec3d, net.minecraft.world.phys.Vec3 vec3d1, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) {
+ // most of this code comes from IBlockAccess#a(RayTrace, BiFunction, Function), but removes the needless functions
+ if (vec3d.equals(vec3d1)) {
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
+ }
+
+ double endX = Mth.lerp(-1.0E-7D, vec3d1.x, vec3d.x);
+ double endY = Mth.lerp(-1.0E-7D, vec3d1.y, vec3d.y);
+ double endZ = Mth.lerp(-1.0E-7D, vec3d1.z, vec3d.z);
+
+ double startX = Mth.lerp(-1.0E-7D, vec3d.x, vec3d1.x);
+ double startY = Mth.lerp(-1.0E-7D, vec3d.y, vec3d1.y);
+ double startZ = Mth.lerp(-1.0E-7D, vec3d.z, vec3d1.z);
+
+ int currentX = Mth.floor(startX);
+ int currentY = Mth.floor(startY);
+ int currentZ = Mth.floor(startZ);
+
+ BlockPos.MutableBlockPos currentBlock = new BlockPos.MutableBlockPos(currentX, currentY, currentZ);
+
+ LevelChunk chunk = this.getChunkIfLoaded(currentBlock);
+ if (chunk == null) {
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
+ }
+
+ net.minecraft.world.phys.BlockHitResult.Type initialCheck = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll);
+
+ if (initialCheck != null) {
+ return initialCheck;
+ }
+
+ double diffX = endX - startX;
+ double diffY = endY - startY;
+ double diffZ = endZ - startZ;
+
+ int xDirection = Mth.sign(diffX);
+ int yDirection = Mth.sign(diffY);
+ int zDirection = Mth.sign(diffZ);
+
+ double normalizedX = xDirection == 0 ? Double.MAX_VALUE : (double) xDirection / diffX;
+ double normalizedY = yDirection == 0 ? Double.MAX_VALUE : (double) yDirection / diffY;
+ double normalizedZ = zDirection == 0 ? Double.MAX_VALUE : (double) zDirection / diffZ;
+
+ double normalizedXDirection = normalizedX * (xDirection > 0 ? 1.0D - Mth.frac(startX) : Mth.frac(startX));
+ double normalizedYDirection = normalizedY * (yDirection > 0 ? 1.0D - Mth.frac(startY) : Mth.frac(startY));
+ double normalizedZDirection = normalizedZ * (zDirection > 0 ? 1.0D - Mth.frac(startZ) : Mth.frac(startZ));
+
+ net.minecraft.world.phys.BlockHitResult.Type result;
+
+ do {
+ if (normalizedXDirection > 1.0D && normalizedYDirection > 1.0D && normalizedZDirection > 1.0D) {
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
+ }
+
+ if (normalizedXDirection < normalizedYDirection) {
+ if (normalizedXDirection < normalizedZDirection) {
+ currentX += xDirection;
+ normalizedXDirection += normalizedX;
+ } else {
+ currentZ += zDirection;
+ normalizedZDirection += normalizedZ;
+ }
+ } else if (normalizedYDirection < normalizedZDirection) {
+ currentY += yDirection;
+ normalizedYDirection += normalizedY;
+ } else {
+ currentZ += zDirection;
+ normalizedZDirection += normalizedZ;
+ }
+
+ currentBlock.set(currentX, currentY, currentZ);
+ if (chunk.getPos().x != currentBlock.getX() >> 4 || chunk.getPos().z != currentBlock.getZ() >> 4) {
+ chunk = this.getChunkIfLoaded(currentBlock);
+ if (chunk == null) {
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
+ }
+ }
+ result = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll);
+ } while (result == null);
+
+ return result;
+ }
+ // Kaiiju end
+
public boolean isInWorldBounds(BlockPos pos) {
return pos.isInsideBuildHeightAndWorldBoundsHorizontal(this); // Paper - use better/optimized check
}

View File

@@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Wed, 10 May 2023 17:58:37 +0300
Subject: [PATCH] Fix off thread spider addEffect
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
index 0c36bb47bd7040f1544817810e1c87157cdaff96..089c7bc00b8b4354d795cd864dc2c310bcf6de86 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java
@@ -180,7 +180,9 @@ public class Spider extends Monster {
MobEffect mobeffectlist = entityspider_groupdataspider.effect;
if (mobeffectlist != null) {
+ this.getBukkitEntity().taskScheduler.schedule(task -> { // Kaiiju - Fix off thread spider add effect
this.addEffect(new MobEffectInstance(mobeffectlist, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit
+ }, null, 1); // Kaiiju - Fix off thread spider add effect
}
}

View File

@@ -0,0 +1,143 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Thu, 11 May 2023 05:02:40 +0300
Subject: [PATCH] Add SIMD utilities
Patch from Pufferfish
diff --git a/build.gradle.kts b/build.gradle.kts
index 4686019a152114e63e997ee103fc8424b24b4581..0851203a4bed670242afc5ac86562075f32693ab 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -58,6 +58,14 @@ dependencies {
}
val craftbukkitPackageVersion = "1_19_R3" // Paper
+
+// Kaiiju start - Pufferfish - SIMD utilities
+tasks.withType<JavaCompile> {
+ val compilerArgs = options.compilerArgs
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
+}
+// Kaiiju end
+
tasks.jar {
archiveClassifier.set("dev")
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
new file mode 100644
index 0000000000000000000000000000000000000000..586b4cd007b3b106966524e2697edddf88e3ac9d
--- /dev/null
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
@@ -0,0 +1,59 @@
+package gg.pufferfish.pufferfish.simd;
+
+import org.bukkit.Bukkit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import jdk.incubator.vector.FloatVector;
+import jdk.incubator.vector.IntVector;
+import jdk.incubator.vector.VectorSpecies;
+
+/**
+ * Basically, java is annoying and we have to push this out to its own class.
+ */
+public class SIMDChecker {
+
+ public static boolean canEnable(Logger logger) {
+ try {
+ if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19) {
+ return false;
+ } else {
+ SIMDDetection.testRun = true;
+
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
+
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + ISPEC.vectorBitSize() + " bits (int)");
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
+
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
+ logger.log(Level.WARNING, "SIMD is not properly supported on this system!");
+ return false;
+ }
+
+ return true;
+ }
+ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
+ return false;
+ }
+
+ public static void simdWarning() {
+ // Attempt to detect vectorization
+ try {
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(Bukkit.getLogger());
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19;
+ } catch (NoClassDefFoundError | Exception ignored) {
+ ignored.printStackTrace();
+ }
+
+ if (SIMDDetection.isEnabled) {
+ Bukkit.getLogger().info("SIMD operations detected as functional. Will replace some operations with faster versions.");
+ } else if (SIMDDetection.versionLimited) {
+ Bukkit.getLogger().warning("Will not enable SIMD! These optimizations are only safely supported on Java 17, Java 18, and Java 19.");
+ } else {
+ Bukkit.getLogger().warning("SIMD operations are available for your server, but are not configured!");
+ Bukkit.getLogger().warning("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");
+ Bukkit.getLogger().warning("If you have already added this flag, then SIMD operations are not supported on your JVM or CPU.");
+ Bukkit.getLogger().warning("Debug: Java: " + System.getProperty("java.version") + ", test run: " + SIMDDetection.testRun);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
new file mode 100644
index 0000000000000000000000000000000000000000..758fa97304a32bf17935c86dc03cbf50606935d8
--- /dev/null
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
@@ -0,0 +1,32 @@
+package gg.pufferfish.pufferfish.simd;
+
+import java.util.logging.Logger;
+
+public class SIMDDetection {
+
+ public static boolean isEnabled = false;
+ public static boolean versionLimited = false;
+ public static boolean testRun = false;
+
+ public static boolean canEnable(Logger logger) {
+ try {
+ return SIMDChecker.canEnable(logger);
+ } catch (NoClassDefFoundError | Exception ignored) {
+ return false;
+ }
+ }
+
+ public static int getJavaVersion() {
+ // https://stackoverflow.com/a/2591122
+ String version = System.getProperty("java.version");
+ if(version.startsWith("1.")) {
+ version = version.substring(2, 3);
+ } else {
+ int dot = version.indexOf(".");
+ if(dot != -1) { version = version.substring(0, dot); }
+ }
+ version = version.split("-")[0]; // Azul is stupid
+ return Integer.parseInt(version);
+ }
+
+}
\ 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 426777730f77664c69bd0a084a9323d767ebc0ad..5272164b18c2ca999c4744aede32f4a4c72525ed 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -225,6 +225,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
DedicatedServer.LOGGER.error("Unable to load server configuration", e);
return false;
}
+ gg.pufferfish.pufferfish.simd.SIMDChecker.simdWarning();
dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands();
// Kaiiju end
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now

View File

@@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Thu, 11 May 2023 17:12:34 +0300
Subject: [PATCH] Toggle shared random for players
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index f1fe094c4b4c5932ba656165bb1671020c1277a5..d3f6e5c873255d00160cf792898204a82a0ec5e8 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -208,8 +208,10 @@ public class KaiijuConfig {
}
public static String serverModName = "Kaiiju";
+ public static boolean sharedRandomForPlayers = true;
private static void gameplaySettings() {
serverModName = getString("gameplay.server-mod-name", serverModName);
+ sharedRandomForPlayers = getBoolean("gameplay.shared-random-for-players", sharedRandomForPlayers);
}
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 08e61a8940c142c68ed93359084ea46c7fd52310..f22b4ad629845462656834abb3e28d2c2588ace6 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -560,6 +560,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.bb = Entity.INITIAL_AABB;
this.stuckSpeedMultiplier = Vec3.ZERO;
this.nextStep = 1.0F;
+ // Kaiiju start - Toggle shared random for players
+ if (!dev.kaiijumc.kaiiju.KaiijuConfig.sharedRandomForPlayers && this instanceof Player)
+ this.random = RandomSource.create();
+ else
+ // Kaiiju end
this.random = SHARED_RANDOM; // Paper
this.remainingFireTicks = -this.getFireImmuneTicks();
this.fluidHeight = new Object2DoubleArrayMap(2);

View File

@@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Sun, 14 May 2023 18:50:57 +0300
Subject: [PATCH] Kick player instead of crashing
diff --git a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
index d52a522fe6d5c4375862691fa32450bc458ca38b..648aff395887d2f13846b1bbe59f4115206ad7cf 100644
--- a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
+++ b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
@@ -486,7 +486,12 @@ public class RegionizedPlayerChunkLoader {
new ChunkPos(chunkX, chunkZ), new MutableObject<>(), false, true); // unloaded, loaded
return;
}
- throw new IllegalStateException();
+ // Kaiiju - Kick player instead of crashing
+ String errorMsg = "Already sent chunk [" + chunkX + ", " + chunkZ + "] in world " + this.world;
+ this.player.getBukkitEntity().kickPlayer(errorMsg);
+ org.bukkit.Bukkit.getLogger().severe(errorMsg);
+ // throw new IllegalStateException();
+ // Kaiiju end
}
private void sendUnloadChunk(final int chunkX, final int chunkZ) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 5ccfc95f51a899b1cd3f34af5e5bb05d902016b8..9c20bd199454b6032a6a90676d12526168b8dd0b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -133,7 +133,12 @@ public class ChunkHolder {
public void addPlayer(ServerPlayer player) {
if (!this.playersSentChunkTo.add(player)) {
- throw new IllegalStateException("Already sent chunk " + this.pos + " in world '" + this.chunkMap.level.getWorld().getName() + "' to player " + player);
+ // Kaiiju start - Kick player instead of crashing
+ String errorMsg = "Already sent chunk " + this.pos + " in world " + this.chunkMap.level.getWorld().getName();
+ player.getBukkitEntity().kickPlayer(errorMsg);
+ org.bukkit.Bukkit.getLogger().severe(errorMsg);
+ //throw new IllegalStateException("Already sent chunk " + this.pos + " in world '" + this.chunkMap.level.getWorld().getName() + "' to player " + player);
+ // Kaiiju end
}
}

View 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() {