Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae5526ff76 | ||
|
|
f6f2314be6 | ||
|
|
4e5feda68f | ||
|
|
b6729158b0 | ||
|
|
d4cd2cf5b3 | ||
|
|
c4741b284e | ||
|
|
65ee54da34 | ||
|
|
7ebfac20b8 | ||
|
|
fa210d634d | ||
|
|
91eaf9966d | ||
|
|
3bc1986806 | ||
|
|
3f3c9292bf |
35
README.md
35
README.md
@@ -12,13 +12,36 @@
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
### Additions
|
### Main additions
|
||||||
- **Xymb Linear Format**: Saves about 50% of disk space in OW and Nether and 95% in The End.
|
- **Xymb Linear Format**: Saves about 50% of disk space in OW/Nether and 95% in The End.
|
||||||
- **Auto update**: Update upstream everyday.
|
- **Auto update**: Automatic upstream updates.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
region-format:
|
||||||
|
debug: false
|
||||||
|
network:
|
||||||
|
send-null-entity-packets: true
|
||||||
|
alternate-keepalive: false
|
||||||
|
gameplay:
|
||||||
|
server-mod-name: Kaiiju
|
||||||
|
world-settings:
|
||||||
|
default:
|
||||||
|
region-format:
|
||||||
|
format: LINEAR
|
||||||
|
linear:
|
||||||
|
compression-level: 1
|
||||||
|
crash-on-broken-symlink: true
|
||||||
|
gameplay:
|
||||||
|
shulker-box-drop-contents-when-destroyed: true
|
||||||
|
```
|
||||||
|
|
||||||
### Roadmap
|
### Roadmap
|
||||||
- **Static view distance**: Reduce RAM usage with a "cached" view distance.
|
- **Static view distance**: Reduce RAM usage / Region size with a "static" view distance.
|
||||||
- **Native world conversion**: Convert region file format at startup
|
- **Linear timestamps**: Add chunk timestamps to linear region files.
|
||||||
|
- **Native world conversion**: Convert region file format at startup.
|
||||||
|
- **Stash deduplication**: Make giant dupe stashes possible and lagless.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
@@ -29,5 +52,3 @@
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
Original patches are licensed under GPL-3.0.
|
Original patches are licensed under GPL-3.0.
|
||||||
|
|
||||||
Made with <span style="color: #e25555;">♥</span> on Earth.
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import io.papermc.paperweight.util.constants.*
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
id("io.papermc.paperweight.patcher") version "1.5.1"
|
id("io.papermc.paperweight.patcher") version "1.5.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@@ -30,8 +30,8 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||||
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
|
decompiler("net.minecraftforge:forgeflower:2.0.629.0")
|
||||||
paperclip("io.papermc:paperclip:3.0.2")
|
paperclip("io.papermc:paperclip:3.0.3")
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
@@ -72,36 +72,35 @@ paperweight {
|
|||||||
serverOutputDir.set(layout.projectDirectory.dir("kaiiju-server"))
|
serverOutputDir.set(layout.projectDirectory.dir("kaiiju-server"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.register("foliaRefLatest") {
|
tasks.register("foliaRefLatest") {
|
||||||
// Update the foliaRef in gradle.properties to be the latest commit.
|
// Update the foliaRef in gradle.properties to be the latest commit.
|
||||||
val tempDir = layout.cacheDir("foliaRefLatest");
|
val tempDir = layout.cacheDir("foliaRefLatest");
|
||||||
val file = "gradle.properties";
|
val file = "gradle.properties";
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
data class GithubCommit(
|
data class GithubCommit(
|
||||||
val sha: String
|
val sha: String
|
||||||
)
|
)
|
||||||
|
|
||||||
val foliaLatestCommitJson = layout.cache.resolve("foliaLatestCommit.json");
|
val foliaLatestCommitJson = layout.cache.resolve("foliaLatestCommit.json");
|
||||||
download.get().download("https://api.github.com/repos/PaperMC/Folia/commits/master", foliaLatestCommitJson);
|
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 foliaLatestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(foliaLatestCommitJson)["sha"].asString;
|
||||||
|
|
||||||
copy {
|
copy {
|
||||||
from(file)
|
from(file)
|
||||||
into(tempDir)
|
into(tempDir)
|
||||||
filter { line: String ->
|
filter { line: String ->
|
||||||
line.replace("foliaRef = .*".toRegex(), "foliaRef = $foliaLatestCommit")
|
line.replace("foliaRef = .*".toRegex(), "foliaRef = $foliaLatestCommit")
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
doLast {
|
|
||||||
copy {
|
|
||||||
from(tempDir.file("gradle.properties"))
|
|
||||||
into(project.file(file).parent)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
copy {
|
||||||
|
from(tempDir.file("gradle.properties"))
|
||||||
|
into(project.file(file).parent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ group = dev.kaiijumc.kaiiju
|
|||||||
version = 1.19.4-R0.1-SNAPSHOT
|
version = 1.19.4-R0.1-SNAPSHOT
|
||||||
mcVersion = 1.19.4
|
mcVersion = 1.19.4
|
||||||
|
|
||||||
foliaRef = 25e0cbdae46912d227a31703869594538b731931
|
foliaRef = b97116b7b2236ca422150d93de5fd1fc8f08de17
|
||||||
|
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
288
gradlew
vendored
288
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with 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
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# This is normally unused
|
||||||
APP_BASE_NAME=`basename "$0"`
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
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 [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
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."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
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.
|
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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,80 +137,109 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# 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" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --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
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
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" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
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
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -109,10 +109,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
|
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
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696d4cdd0cc
|
index 0000000000000000000000000000000000000000..245e3b1801c5f92054d9c0d0d8fc2a8fcfd6a1d4
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||||
@@ -0,0 +1,336 @@
|
@@ -0,0 +1,328 @@
|
||||||
+package dev.kaiijumc.kaiiju.region;
|
+package dev.kaiijumc.kaiiju.region;
|
||||||
+
|
+
|
||||||
+import com.github.luben.zstd.ZstdInputStream;
|
+import com.github.luben.zstd.ZstdInputStream;
|
||||||
@@ -133,15 +133,25 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+import java.nio.file.Path;
|
+import java.nio.file.Path;
|
||||||
+import java.nio.file.StandardCopyOption;
|
+import java.nio.file.StandardCopyOption;
|
||||||
+import java.util.ArrayList;
|
+import java.util.ArrayList;
|
||||||
|
+import java.util.Arrays;
|
||||||
+import java.util.concurrent.locks.ReentrantLock;
|
+import java.util.concurrent.locks.ReentrantLock;
|
||||||
+
|
+
|
||||||
+public class LinearRegionFile extends Thread implements AbstractRegionFile {
|
+public class LinearRegionFile extends Thread implements AbstractRegionFile {
|
||||||
|
+ private static long SUPERBLOCK = -4323716122432332390L;
|
||||||
|
+ private static byte VERSION = 1;
|
||||||
|
+ private static int HEADER_SIZE = 32;
|
||||||
|
+ private static int FOOTER_SIZE = 8;
|
||||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
+ private final byte[][] buffer = new byte[32*32][];
|
+
|
||||||
+ private final int[] bufferUncompressedSize = new int[32*32];
|
+
|
||||||
|
+ private final byte[][] buffer = new byte[1024][];
|
||||||
|
+ private final int[] bufferUncompressedSize = new int[1024];
|
||||||
+
|
+
|
||||||
+ private final Object markedToSaveLock = new Object();
|
+ 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 markedToSave = false;
|
||||||
+ private boolean close = false;
|
+ private boolean close = false;
|
||||||
@@ -162,69 +172,60 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
||||||
+ this.regionFile = file;
|
+ this.regionFile = file;
|
||||||
+ this.compressionLevel = compression;
|
+ this.compressionLevel = compression;
|
||||||
|
+
|
||||||
|
+ this.compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||||
|
+ this.decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||||
|
+
|
||||||
+ File regionFile = new File(this.regionFile.toString());
|
+ File regionFile = new File(this.regionFile.toString());
|
||||||
+
|
+
|
||||||
+ LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
|
+ Arrays.fill(this.bufferUncompressedSize, 0);
|
||||||
+
|
|
||||||
+ for (int i = 0; i < 32 * 32; i++)
|
|
||||||
+ this.bufferUncompressedSize[i] = 0;
|
|
||||||
+
|
+
|
||||||
+ if(regionFile.canRead()) {
|
+ if(regionFile.canRead()) {
|
||||||
+ long fileLength = file.toFile().length();
|
|
||||||
+ FileInputStream fileStream = new FileInputStream(regionFile);
|
+ FileInputStream fileStream = new FileInputStream(regionFile);
|
||||||
+ DataInputStream rawDataStream = new DataInputStream(fileStream);
|
+ DataInputStream rawDataStream = new DataInputStream(fileStream);
|
||||||
+
|
+
|
||||||
+ long SUPERBLOCK = -4323716122432332390L;
|
|
||||||
+ byte VERSION = 1;
|
|
||||||
+ int HEADER_SIZE = 32;
|
|
||||||
+ int FOOTER_SIZE = 8;
|
|
||||||
+
|
|
||||||
+ long superBlock = rawDataStream.readLong();
|
+ long superBlock = rawDataStream.readLong();
|
||||||
+
|
|
||||||
+ if (superBlock != SUPERBLOCK)
|
+ if (superBlock != SUPERBLOCK)
|
||||||
+ throw new RuntimeException("Superblock invalid: " + superBlock + " file " + file);
|
+ throw new RuntimeException("Superblock invalid: " + superBlock + " file " + file);
|
||||||
+
|
+
|
||||||
+ byte version = rawDataStream.readByte();
|
+ byte version = rawDataStream.readByte();
|
||||||
+
|
|
||||||
+ if (version != VERSION)
|
+ if (version != VERSION)
|
||||||
+ throw new RuntimeException("Version invalid: " + version + " file " + file);
|
+ throw new RuntimeException("Version invalid: " + version + " file " + file);
|
||||||
+
|
+
|
||||||
+ rawDataStream.readLong(); // newestTimestamp
|
+ // Skip newestTimestamp (Long) + Compression level (Byte) + Chunk count (Short): Unused.
|
||||||
+ rawDataStream.readByte(); // Compression level
|
+ rawDataStream.skipBytes(11);
|
||||||
+ rawDataStream.readShort(); // Chunk count
|
|
||||||
+ int dataCount = rawDataStream.readInt();
|
|
||||||
+
|
+
|
||||||
|
+ int dataCount = rawDataStream.readInt();
|
||||||
|
+ long fileLength = file.toFile().length();
|
||||||
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE)
|
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE)
|
||||||
+ throw new IOException("File length invalid " + this.regionFile + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
+ throw new IOException("File length invalid " + this.regionFile + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||||
+
|
+
|
||||||
+ rawDataStream.readLong(); // Data Hash
|
+ rawDataStream.skipBytes(8); // Skip data hash (Long): Unused.
|
||||||
+ byte[] rawCompressed = new byte[dataCount];
|
|
||||||
+
|
+
|
||||||
|
+ byte[] rawCompressed = new byte[dataCount];
|
||||||
+ rawDataStream.readFully(rawCompressed, 0, dataCount);
|
+ rawDataStream.readFully(rawCompressed, 0, dataCount);
|
||||||
+
|
+
|
||||||
+ superBlock = rawDataStream.readLong();
|
+ superBlock = rawDataStream.readLong();
|
||||||
+
|
+ if (superBlock != SUPERBLOCK)
|
||||||
+ if (superBlock != SUPERBLOCK) {
|
|
||||||
+ throw new IOException("Footer superblock invalid " + this.regionFile);
|
+ throw new IOException("Footer superblock invalid " + this.regionFile);
|
||||||
+ }
|
|
||||||
+
|
+
|
||||||
+ DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)));
|
+ DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)));
|
||||||
+
|
+
|
||||||
+ int[] starts = new int[32 * 32];
|
+ int[] starts = new int[1024];
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
+ for(int i = 0; i < 1024; i++) {
|
||||||
+ starts[i] = dataStream.readInt();
|
+ starts[i] = dataStream.readInt();
|
||||||
+ dataStream.readInt(); // Skip timestamps
|
+ dataStream.skipBytes(4); // Skip timestamps (Int): Unimplemented TODO: Implement per-chunk timestamps
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
+ for(int i = 0; i < 1024; i++) {
|
||||||
+ if(starts[i] > 0) {
|
+ if(starts[i] > 0) {
|
||||||
+ int size = starts[i];
|
+ int size = starts[i];
|
||||||
+ byte[] b = new byte[size];
|
+ byte[] b = new byte[size];
|
||||||
+ dataStream.readFully(b, 0, size);
|
+ dataStream.readFully(b, 0, size);
|
||||||
+
|
+
|
||||||
+ int maxCompressedLength = compressor.maxCompressedLength(size);
|
+ int maxCompressedLength = this.compressor.maxCompressedLength(size);
|
||||||
+ byte[] compressed = new byte[maxCompressedLength];
|
+ 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];
|
+ b = new byte[compressedLength];
|
||||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||||
+
|
+
|
||||||
@@ -264,9 +265,7 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ }
|
+ }
|
||||||
+ for(int i = 0 ; i < 100 ; i++) {
|
+ for(int i = 0 ; i < 100 ; i++) {
|
||||||
+ Thread.sleep(100);
|
+ Thread.sleep(100);
|
||||||
+ if(close) {
|
+ if(close) return;
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ } catch(InterruptedException ignored) {}
|
+ } catch(InterruptedException ignored) {}
|
||||||
@@ -277,11 +276,8 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public synchronized void flush() throws IOException {
|
+ public synchronized void flush() throws IOException {
|
||||||
+ if(!isMarkedToSave())
|
+ if(!isMarkedToSave()) return;
|
||||||
+ return;
|
|
||||||
+
|
+
|
||||||
+ long SUPERBLOCK = -4323716122432332390L;
|
|
||||||
+ byte VERSION = 1;
|
|
||||||
+ long timestamp = System.currentTimeMillis() / 1000L;
|
+ long timestamp = System.currentTimeMillis() / 1000L;
|
||||||
+ short chunkCount = 0;
|
+ short chunkCount = 0;
|
||||||
+
|
+
|
||||||
@@ -299,23 +295,21 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ dataStream.writeLong(timestamp);
|
+ dataStream.writeLong(timestamp);
|
||||||
+ dataStream.writeByte(this.compressionLevel);
|
+ dataStream.writeByte(this.compressionLevel);
|
||||||
+
|
+
|
||||||
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
|
||||||
+
|
|
||||||
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
|
+ 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) {
|
+ if(this.bufferUncompressedSize[i] != 0) {
|
||||||
+ chunkCount += 1;
|
+ chunkCount += 1;
|
||||||
+ byte[] content = new byte[bufferUncompressedSize[i]];
|
+ 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);
|
+ byteBuffers.add(content);
|
||||||
+ } else byteBuffers.add(null);
|
+ } else byteBuffers.add(null);
|
||||||
+ }
|
+ }
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
+ for(int i = 0; i < 1024; i++) {
|
||||||
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]);
|
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]);
|
||||||
+ zstdDataStream.writeInt(0);
|
+ zstdDataStream.writeInt(0); // TODO: IMPLEMENT PER CHUNK TIMESTAMPS
|
||||||
+ }
|
+ }
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
+ for(int i = 0; i < 1024; i++) {
|
||||||
+ if(byteBuffers.get(i) != null)
|
+ if(byteBuffers.get(i) != null)
|
||||||
+ zstdDataStream.write(byteBuffers.get(i), 0, byteBuffers.get(i).length);
|
+ zstdDataStream.write(byteBuffers.get(i), 0, byteBuffers.get(i).length);
|
||||||
+ }
|
+ }
|
||||||
@@ -345,14 +339,13 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public synchronized void write(ChunkPos pos, ByteBuffer buffer) {
|
+ public synchronized void write(ChunkPos pos, ByteBuffer buffer) {
|
||||||
+ LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
|
|
||||||
+ try {
|
+ try {
|
||||||
+ byte[] b = toByteArray(new ByteArrayInputStream(buffer.array()));
|
+ byte[] b = toByteArray(new ByteArrayInputStream(buffer.array()));
|
||||||
+ int uncompressedSize = b.length;
|
+ int uncompressedSize = b.length;
|
||||||
+
|
+
|
||||||
+ int maxCompressedLength = compressor.maxCompressedLength(b.length);
|
+ int maxCompressedLength = this.compressor.maxCompressedLength(b.length);
|
||||||
+ byte[] compressed = new byte[maxCompressedLength];
|
+ 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];
|
+ b = new byte[compressedLength];
|
||||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||||
+
|
+
|
||||||
@@ -399,9 +392,8 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ @Nullable
|
+ @Nullable
|
||||||
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
|
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
|
||||||
+ if(this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
|
+ if(this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
|
||||||
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
|
||||||
+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]];
|
+ 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 new DataInputStream(new ByteArrayInputStream(content));
|
||||||
+ }
|
+ }
|
||||||
+ return null;
|
+ return null;
|
||||||
@@ -432,7 +424,7 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static int getChunkIndex(int x, int z) {
|
+ private static int getChunkIndex(int x, int z) {
|
||||||
+ return (x & 31) + (z & 31) * 32;
|
+ return (x & 31) + ((z & 31) << 5);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public boolean recalculateHeader() {
|
+ public boolean recalculateHeader() {
|
||||||
@@ -537,7 +529,7 @@ index 513833c2ea23df5b079d157bc5cb89d5c9754c0b..a62a1b281bd0b6ad7d59b45b9470d84f
|
|||||||
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
+++ b/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
|
@@ -272,7 +272,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
@@ -558,7 +550,7 @@ index 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d6
|
|||||||
this.setViewDistance(viewDistance);
|
this.setViewDistance(viewDistance);
|
||||||
// Paper start
|
// Paper start
|
||||||
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
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"
|
// Paper start - chunk status cache "api"
|
||||||
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
||||||
@@ -574,7 +566,7 @@ index 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d6
|
|||||||
|
|
||||||
if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
|
if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
|
||||||
return null;
|
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 {
|
public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ index 52c2e0fe73a5af18535a2b0b9a506919e3f93003..ea54af3f68c6534ff5a71ca0b7a99d12
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
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..f0066cc8dc8069f97008c36cf2cfc7377e201dde 100644
|
index c9fbba6f709ed0540dcc22b41e50ce9d01a6381c..70e3ee306283263cdcdb7a66c80fc23484385aac 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
+++ b/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;
|
@@ -20,6 +20,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||||
@@ -203,6 +203,14 @@ index c9fbba6f709ed0540dcc22b41e50ce9d01a6381c..f0066cc8dc8069f97008c36cf2cfc737
|
|||||||
if (java.nio.file.Files.exists(anvil)) path1 = anvil;
|
if (java.nio.file.Files.exists(anvil)) path1 = anvil;
|
||||||
else if (java.nio.file.Files.exists(linear)) path1 = linear;
|
else if (java.nio.file.Files.exists(linear)) path1 = linear;
|
||||||
else {
|
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
|
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
|
index 414aa3ae00c2d28e754235e3e93b6b623d4fd180..15e376fac063430e4355c6ffcd25c35a8ce20c5b 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||||
|
|||||||
35
patches/server/0012-Purpur-Gameplay-FixVoidTrading.patch
Normal file
35
patches/server/0012-Purpur-Gameplay-FixVoidTrading.patch
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 23 Apr 2023 15:34:30 +0300
|
||||||
|
Subject: [PATCH] Purpur Gameplay FixVoidTrading
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 0f0cfd958f7d2c6d2ca4192be1b986900a2bfa53..c267b0cd52448246c7701081028ff0986dde2fa2 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -147,8 +147,10 @@ public class KaiijuWorldConfig {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||||
|
+ public boolean fixVoidTrading = true;
|
||||||
|
|
||||||
|
private void gameplaySettings() {
|
||||||
|
shulkerBoxDropContentsWhenDestroyed = getBoolean("gameplay.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
|
+ fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
index 35ae624be25b66d5615dc19cbe7eb8785c7029b5..92cc38353d25f3749186dbc062402c9bafb25fca 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -2824,7 +2824,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
// Spigot Start
|
||||||
|
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
||||||
|
// Paper start
|
||||||
|
- if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
|
||||||
|
+ if (entity.level.kaiijuConfig.fixVoidTrading && entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) { // Kaiiju
|
||||||
|
merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED);
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
101
patches/todo/0012-Static-Distance-WIP.patch
Normal file
101
patches/todo/0012-Static-Distance-WIP.patch
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Wed, 19 Apr 2023 02:37:04 +0300
|
||||||
|
Subject: [PATCH] Static Distance WIP
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||||
|
index e77972c4c264100ffdd824bfa2dac58dbbc6d678..cddacd6d5bbe97641bd23f5c067012907d9c5c01 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||||
|
@@ -75,6 +75,17 @@ public final class PlayerChunkLoader {
|
||||||
|
return data.getTargetSendViewDistance();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
+ public static int getStaticDistance(final ServerPlayer player) {
|
||||||
|
+ final ServerLevel level = (ServerLevel)player.level;
|
||||||
|
+ final PlayerLoaderData data = level.chunkSource.chunkMap.playerChunkManager.getData(player);
|
||||||
|
+ if (data == null) {
|
||||||
|
+ return level.chunkSource.chunkMap.playerChunkManager.getTargetStaticDistance();
|
||||||
|
+ }
|
||||||
|
+ return data.getTargetSendViewDistance();
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
protected final ChunkMap chunkMap;
|
||||||
|
protected final Reference2ObjectLinkedOpenHashMap<ServerPlayer, PlayerLoaderData> playerMap = new Reference2ObjectLinkedOpenHashMap<>(512, 0.7f);
|
||||||
|
protected final ReferenceLinkedOpenHashSet<PlayerLoaderData> chunkSendQueue = new ReferenceLinkedOpenHashSet<>(512, 0.7f);
|
||||||
|
@@ -132,6 +143,12 @@ public final class PlayerChunkLoader {
|
||||||
|
|
||||||
|
// no throttling is applied below this VD for loading
|
||||||
|
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
+ public final PlayerAreaMap staticMap;
|
||||||
|
+ protected int rawStaticDistance = -1;
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* The chunks to be sent to players, provided they're send-ready. Send-ready means the chunk and its 1 radius neighbours are loaded.
|
||||||
|
*/
|
||||||
|
@@ -190,6 +207,12 @@ public final class PlayerChunkLoader {
|
||||||
|
return this.rawSendDistance == -1 ? this.getLoadDistance() : this.rawSendDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
+ public int getTargetStaticDistance() {
|
||||||
|
+ return this.rawStaticDistance == -1 ? this.getStaticDistance() : this.rawStaticDistance;
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
public void setTargetSendDistance(final int distance) {
|
||||||
|
this.setSendDistance(distance);
|
||||||
|
}
|
||||||
|
@@ -231,6 +254,16 @@ public final class PlayerChunkLoader {
|
||||||
|
this.rawTickDistance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
+ public void setStaticDistance(final int distance) {
|
||||||
|
+ this.rawStaticDistance = distance;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int getStaticDistance() {
|
||||||
|
+ return this.rawStaticDistance;
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
Players have 3 different types of view distance:
|
||||||
|
1. Sending view distance
|
||||||
|
@@ -256,7 +289,13 @@ public final class PlayerChunkLoader {
|
||||||
|
|
||||||
|
public PlayerChunkLoader(final ChunkMap chunkMap, final PooledLinkedHashSets<ServerPlayer> pooledHashSets) {
|
||||||
|
this.chunkMap = chunkMap;
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
this.broadcastMap = new PlayerAreaMap(pooledHashSets,
|
||||||
|
+ null,
|
||||||
|
+ (ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
|
||||||
|
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newState) -> {});
|
||||||
|
+ // Kaiiju end
|
||||||
|
+ this.staticMap = new PlayerAreaMap(pooledHashSets,
|
||||||
|
null,
|
||||||
|
(ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
|
||||||
|
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newState) -> {
|
||||||
|
@@ -807,6 +846,7 @@ public final class PlayerChunkLoader {
|
||||||
|
protected int sendViewDistance = -1;
|
||||||
|
protected int loadViewDistance = -1;
|
||||||
|
protected int tickViewDistance = -1;
|
||||||
|
+ protected int staticViewDistance = -1; // Kaiiju
|
||||||
|
|
||||||
|
protected long nextChunkSendTarget;
|
||||||
|
|
||||||
|
@@ -932,6 +972,7 @@ public final class PlayerChunkLoader {
|
||||||
|
this.loader.loadMap.remove(this.player);
|
||||||
|
this.loader.loadTicketCleanup.remove(this.player);
|
||||||
|
this.loader.tickMap.remove(this.player);
|
||||||
|
+ this.loader.staticMap.remove(this.player); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getClientViewDistance() {
|
||||||
Reference in New Issue
Block a user