Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86c3a4e8de | ||
|
|
c40c8785cd | ||
|
|
e3a38f51cf | ||
|
|
a3812b6cef | ||
|
|
b8868beac9 | ||
|
|
835c7b10d8 | ||
|
|
e7823d7a0a | ||
|
|
e44b800bbe | ||
|
|
5705d55587 | ||
|
|
3c013f180c | ||
|
|
b5121bd590 | ||
|
|
2ac15d9c21 | ||
|
|
eafa041f07 | ||
|
|
89828085c6 | ||
|
|
9c397142c6 | ||
|
|
7e1ad9e37a | ||
|
|
d844c7c954 | ||
|
|
292f587834 | ||
|
|
cd442cc16b | ||
|
|
e6207392bf | ||
|
|
e817028ac1 | ||
|
|
ae74a9bb2c | ||
|
|
fc5216a070 | ||
|
|
2deb7e54f0 | ||
|
|
61e11ce710 | ||
|
|
f935b6ffd5 | ||
|
|
d09ea5c71c | ||
|
|
063da21ea3 | ||
|
|
0ec98213bf | ||
|
|
1a2f815bcf | ||
|
|
e58f00dded | ||
|
|
7d9b65d3d4 | ||
|
|
3afafc910b | ||
|
|
a4fdc32a0b | ||
|
|
6150eef35c | ||
|
|
b516d47aeb | ||
|
|
4dfd98f9b9 | ||
|
|
ac5e38e86e | ||
|
|
dbbc862af3 | ||
|
|
784e2baf7a | ||
|
|
94ca13f790 | ||
|
|
963286ac7e | ||
|
|
0383ff6961 | ||
|
|
8e1bfd6c3c | ||
|
|
1638fe6b97 | ||
|
|
d5699419e4 | ||
|
|
d57758c9f8 | ||
|
|
63d893a0e4 | ||
|
|
08892016f5 | ||
|
|
32ac7246a3 | ||
|
|
4caf0ff2bd | ||
|
|
d4ca1a3765 | ||
|
|
842d7fa834 | ||
|
|
ecad700a9e | ||
|
|
1190cfc22a | ||
|
|
0284282d7f | ||
|
|
229675335e | ||
|
|
620e5d7176 | ||
|
|
41dd32edac | ||
|
|
a32479ac64 | ||
|
|
cf6cc82ebc | ||
|
|
6c6f02d305 | ||
|
|
12f555aa4d | ||
|
|
2d37d7141c | ||
|
|
363fcaec61 | ||
|
|
a7419fafc9 | ||
|
|
c06b0d77a1 | ||
|
|
f07107ec59 | ||
|
|
3ef59980e7 | ||
|
|
e2af449239 | ||
|
|
41c0116446 | ||
|
|
ffbcddccac | ||
|
|
1e2bebf45f | ||
|
|
80f5d58780 |
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@@ -1,20 +1,22 @@
|
||||
name: Generate Jars
|
||||
on: [ push, pull_request ]
|
||||
env:
|
||||
version: '1.19.3'
|
||||
branch: ver/1.19.3
|
||||
version: '1.19.4'
|
||||
branch: ver/1.19.4
|
||||
jobs:
|
||||
paperclip:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2.5.0
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '17'
|
||||
cache: 'gradle'
|
||||
distribution: 'temurin'
|
||||
distribution: 'GraalVM'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: 'latest'
|
||||
- name: Configure Git User Details
|
||||
run: |
|
||||
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||
|
||||
14
.github/workflows/release.yml
vendored
14
.github/workflows/release.yml
vendored
@@ -1,20 +1,22 @@
|
||||
name: Release Jars
|
||||
on: workflow_dispatch
|
||||
on: [push, workflow_dispatch]
|
||||
env:
|
||||
version: '1.19.3'
|
||||
branch: ver/1.19.3
|
||||
version: '1.19.4'
|
||||
branch: ver/1.19.4
|
||||
jobs:
|
||||
paperclip:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2.5.0
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '17'
|
||||
cache: 'gradle'
|
||||
distribution: 'temurin'
|
||||
distribution: 'GraalVM'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: 'latest'
|
||||
- name: Configure Git User Details
|
||||
run: |
|
||||
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||
|
||||
12
README.md
12
README.md
@@ -2,8 +2,7 @@
|
||||
<div align="center">
|
||||
<img src="https://github.com/kugge/Kaiiju/blob/ver/1.19.3/logo.png?" width="32%" height="32%"/>
|
||||
<h1>Kaiiju</h1>
|
||||
<h3>A Server Software Designed For Anarchy</h3>
|
||||
<h4>❗ [ Warning ] Work in progress, contributions are welcome ❗</h4>
|
||||
<h3>Designed for vanilla/anarchy servers</h3>
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/kugge/Kaiiju/actions)
|
||||
@@ -17,8 +16,12 @@
|
||||
- **Xymb Linear Format**: Saves about 50% of disk space in OW and Nether and 95% in The End.
|
||||
- **Lobotomize**: Lobotomize mobs and villagers without breaking vanilla mechanics.
|
||||
|
||||
### Roadmap
|
||||
- **Lithium**: Implementation of Lithium server mixins.
|
||||
- **C2ME**: Implementation of C2ME server mixins.
|
||||
- **VMP**: Implementation of VMP server mixins.
|
||||
|
||||
## Building
|
||||
In order to distribute and use this server software, you need a paperclip file:
|
||||
|
||||
```bash
|
||||
./gradlew applyPatches # Apply Kaiiju patches
|
||||
@@ -26,7 +29,6 @@ In order to distribute and use this server software, you need a paperclip file:
|
||||
```
|
||||
|
||||
## License
|
||||
Patches are licensed under GPL-3.0.
|
||||
All other files are licensed under MIT.
|
||||
Original patches are licensed under GPL-3.0.
|
||||
|
||||
Made with <span style="color: #e25555;">♥</span> on Earth.
|
||||
|
||||
@@ -4,25 +4,11 @@ import io.papermc.paperweight.util.constants.*
|
||||
plugins {
|
||||
java
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
id("io.papermc.paperweight.patcher") version "1.4.1"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://papermc.io/repo/repository/maven-public/") {
|
||||
content { onlyForConfigurations(PAPERCLIP_CONFIG) }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
decompiler("net.minecraftforge:forgeflower:2.0.605.1")
|
||||
paperclip("io.papermc:paperclip:3.0.2")
|
||||
id("io.papermc.paperweight.patcher") version "1.5.1"
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "maven-publish")
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
@@ -31,8 +17,25 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl) {
|
||||
content {
|
||||
onlyForConfigurations(PAPERCLIP_CONFIG)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
|
||||
paperclip("io.papermc:paperclip:3.0.2")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
tasks.withType<JavaCompile> {
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
}
|
||||
@@ -42,15 +45,9 @@ subprojects {
|
||||
tasks.withType<ProcessResources> {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://oss.sonatype.org/content/groups/public/")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://ci.emc.gs/nexus/content/groups/aikar/")
|
||||
maven("https://repo.aikar.co/content/groups/aikar")
|
||||
maven("https://repo.md-5.net/content/repositories/releases/")
|
||||
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
|
||||
maven(paperMavenPublicUrl)
|
||||
maven("https://jitpack.io")
|
||||
}
|
||||
}
|
||||
@@ -58,26 +55,26 @@ subprojects {
|
||||
paperweight {
|
||||
serverProject.set(project(":kaiiju-server"))
|
||||
|
||||
remapRepo.set("https://maven.fabricmc.net/")
|
||||
decompileRepo.set("https://maven.quiltmc.org")
|
||||
remapRepo.set(paperMavenPublicUrl)
|
||||
decompileRepo.set(paperMavenPublicUrl)
|
||||
|
||||
useStandardUpstream("Purpur") {
|
||||
url.set(github("PurpurMC", "Purpur"))
|
||||
ref.set(providers.gradleProperty("purpurRef"))
|
||||
|
||||
withStandardPatcher {
|
||||
apiSourceDirPath.set("Purpur-API")
|
||||
baseName("Purpur")
|
||||
|
||||
apiPatchDir.set(layout.projectDirectory.dir("patches/api"))
|
||||
apiOutputDir.set(layout.projectDirectory.dir("kaiiju-api"))
|
||||
|
||||
serverSourceDirPath.set("Purpur-Server")
|
||||
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
||||
serverOutputDir.set(layout.projectDirectory.dir("kaiiju-server"))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("purpurRefLatest") {
|
||||
// Update the paperRef in gradle.properties to be the latest commit.3
|
||||
// Update the purpurRef in gradle.properties to be the latest commit.
|
||||
val tempDir = layout.cacheDir("purpurRefLatest");
|
||||
val file = "gradle.properties";
|
||||
|
||||
@@ -87,7 +84,7 @@ paperweight {
|
||||
)
|
||||
|
||||
val purpurLatestCommitJson = layout.cache.resolve("purpurLatestCommit.json");
|
||||
download.get().download("https://api.github.com/repos/PurpurMC/Purpur/commits/ver/1.19.3", purpurLatestCommitJson);
|
||||
download.get().download("https://api.github.com/repos/PurpurMC/Purpur/commits/ver/1.19.4", purpurLatestCommitJson);
|
||||
val purpurLatestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(purpurLatestCommitJson)["sha"].asString;
|
||||
|
||||
copy {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
group = dev.kugge.kaiiju
|
||||
version = 1.19.3-R0.1-SNAPSHOT
|
||||
mcVersion = 1.19.3
|
||||
group = dev.kaiijumc.kaiiju
|
||||
version = 1.19.4-R0.1-SNAPSHOT
|
||||
mcVersion = 1.19.4
|
||||
|
||||
purpurRef = 08aa4dccaad7e5d31ca51b53489d2d413e49748d
|
||||
purpurRef = f5a789d40bc8b55efaf69143067e76a9305354c5
|
||||
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.vfs.watch=false
|
||||
org.gradle.jvmargs=-Xmx4G -Dfile.encoding=UTF-8 -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true -Dgraal.SpeculativeGuardMovement=true -Dgraal.WriteableCodeCache=true
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
BIN
logo.png
BIN
logo.png
Binary file not shown.
|
Before Width: | Height: | Size: 4.3 MiB After Width: | Height: | Size: 879 KiB |
@@ -5,37 +5,43 @@ Subject: [PATCH] Kaiiju Rebranding
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 020927dfe9624453311d1d171a10f44344ec8710..c6a4c48b14a8c927284720b79b93ee1aa9df7da6 100644
|
||||
index 22470f0ab8354a9f31a0f195f3fe80f2f5ee2f0e..845cf3838fc014e59b52c0ffa4cae1bc370d9b47 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
@@ -7,8 +7,12 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
- implementation(project(":purpur-api")) // Purpur
|
||||
- implementation("io.papermc.paper:paper-mojangapi:1.19.4-R0.1-SNAPSHOT") // Purpur
|
||||
+ implementation(project(":kaiiju-api")) // Purpur // Kaiiju
|
||||
// Pufferfish start
|
||||
implementation("io.papermc.paper:paper-mojangapi:1.19.3-R0.1-SNAPSHOT") {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
@@ -83,7 +83,7 @@ tasks.jar {
|
||||
+ // Pufferfish start
|
||||
+ implementation("io.papermc.paper:paper-mojangapi:1.19.4-R0.1-SNAPSHOT") {
|
||||
+ exclude("io.papermc.paper", "paper-api")
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
@@ -81,7 +85,7 @@ tasks.jar {
|
||||
attributes(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
"Implementation-Title" to "CraftBukkit",
|
||||
- "Implementation-Version" to "git-Purpur-$implementationVersion", // Purpur
|
||||
+ "Implementation-Version" to "git-Kaiiju-$implementationVersion", // Purpur // Kaiiju
|
||||
- "Implementation-Version" to "git-Purpur-$implementationVersion", // Pufferfish // Purpur
|
||||
+ "Implementation-Version" to "git-Kaiiju-$implementationVersion", // Pufferfish // Purpur // Kaiiju
|
||||
"Implementation-Vendor" to date, // Paper
|
||||
"Specification-Title" to "Bukkit",
|
||||
"Specification-Version" to project.version,
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
index 9713263c3bd34ab8a3bfc0a8797ba0b1b88ed733..0b95cd5305e4559d6dca59011869e5b203d51576 100644
|
||||
index 8cde30544e14f8fc2dac32966ae3c21f8cf3a551..f9e3659dee7171b37a07d9880d7b21857f87ff00 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -593,7 +593,7 @@ public class Metrics {
|
||||
boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
// Only start Metrics, if it's enabled in the config
|
||||
if (config.getBoolean("enabled", true)) {
|
||||
- Metrics metrics = new Metrics("Purpur", serverUUID, logFailedRequests, Bukkit.getLogger()); // Purpur
|
||||
+ Metrics metrics = new Metrics("Kaiiju", serverUUID, logFailedRequests, Bukkit.getLogger()); // Purpur // Kaiiju
|
||||
- Metrics metrics = new Metrics("Purpur", serverUUID, logFailedRequests, Bukkit.getLogger()); // Pufferfish // Purpur
|
||||
+ Metrics metrics = new Metrics("Kaiiju", serverUUID, logFailedRequests, Bukkit.getLogger()); // Pufferfish // Purpur // Kaiiju
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
String minecraftVersion = Bukkit.getVersion();
|
||||
@@ -49,7 +55,7 @@ index 9713263c3bd34ab8a3bfc0a8797ba0b1b88ed733..0b95cd5305e4559d6dca59011869e5b2
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
index fba5dbdb7bcbb55400ef18342c9b54612972a718..c94e00290e21e4bcfac5b137ded704c0848463cc 100644
|
||||
index 462a6eed350fd660ddaf25d567bb6e97b77d0b2b..ecde56de475b5a69e2ad22c1cbe903e6f3d40466 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
@@ -20,7 +20,7 @@ import java.util.stream.StreamSupport;
|
||||
@@ -81,20 +87,23 @@ index fba5dbdb7bcbb55400ef18342c9b54612972a718..c94e00290e21e4bcfac5b137ded704c0
|
||||
org.bukkit.Bukkit.getLogger().warning("Pattern: " + VER_PATTERN.toString());
|
||||
org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion());
|
||||
}
|
||||
@@ -58,13 +58,15 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
@@ -58,6 +58,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
|
||||
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||
//int distance; // Purpur - use field
|
||||
+ /* // Kaiiju
|
||||
+ // Kaiiju start - disable jenkins/api checking
|
||||
+ /*
|
||||
try {
|
||||
int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||
distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
|
||||
} catch (NumberFormatException ignored) {
|
||||
+ */ // Kaiiju
|
||||
@@ -65,6 +67,10 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
versionInfo = versionInfo.replace("\"", "");
|
||||
distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||
- }
|
||||
+ //} // Kaiiju
|
||||
}
|
||||
+ */
|
||||
+ versionInfo = versionInfo.replace("\"", "");
|
||||
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||
+ // Kaiiju end
|
||||
|
||||
switch (distance) {
|
||||
case -1:
|
||||
@@ -125,10 +134,10 @@ index b5b6657e52e4f7a630229bd3ba433438af293e22..afda0d4198398de29a62159fae701b22
|
||||
stringbuilder.append("// ");
|
||||
stringbuilder.append(CrashReport.getErrorComment());
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index cea4447aad2d64db56a76e4ba180dc7326d2e13b..40b4bd2f1a61c2d9a59c9c09b72713401969460b 100644
|
||||
index 2cc20cc768bbbd386972c426d3a131af33612294..5f5e9db2cbde552216c8990054b96443f180cb3b 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -927,7 +927,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -929,7 +929,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
shutdownThread = Thread.currentThread();
|
||||
org.spigotmc.WatchdogThread.doStop(); // Paper
|
||||
if (!isSameThread()) {
|
||||
@@ -138,20 +147,20 @@ index cea4447aad2d64db56a76e4ba180dc7326d2e13b..40b4bd2f1a61c2d9a59c9c09b7271340
|
||||
this.getRunningThread().stop();
|
||||
try {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 4a8aafd341fdad4b5ae326c4759b3381f5061fb5..caf1237491649205f7b3c7ea4fe1d31d567bbafe 100644
|
||||
index bc1a2df0a7ddaf030917e4723994464d77e55d02..c8641ee7cf081b86a461c640ccd70ec4fc39330b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -262,7 +262,7 @@ import javax.annotation.Nullable; // Paper
|
||||
@@ -256,7 +256,7 @@ import javax.annotation.Nullable; // Paper
|
||||
import javax.annotation.Nonnull; // Paper
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
- private final String serverName = "Purpur"; // Paper // Purpur
|
||||
+ private final String serverName = "Kaiiju"; // Paper // Purpur // Kaiiju
|
||||
- private final String serverName = "Purpur"; // Paper // Pufferfish // Purpur
|
||||
+ private final String serverName = "Kaiiju"; // Paper // Pufferfish // Purpur // Kaiiju
|
||||
private final String serverVersion;
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 78ac748859e21a61140e9bff67e4527a8d35b4b6..5e14153433f5c7854a357aad4776b2aad4cd6fa0 100644
|
||||
index cf7ba8724ab68f6955b5ebfa1ba46c4397da32b3..d5b65d6d0e8c8dea86c69b666448e6f6d7d4e9d6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -883,7 +883,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
@@ -177,20 +186,20 @@ index 5402098dce0d64d3dceea51f248d7d366850a74f..2b7a67c339994c34296f7057ffc8822b
|
||||
// (async tasks must live with race-conditions if they attempt to cancel between these few lines of code)
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
index fb87620c742ff7912f5e8ccd2a7930dd605576d9..0f56013165cd61023b4f30a4da424b701e14a8e2 100644
|
||||
index 99597258e8e88cd9e2c901c4ac3ff7faeeabee2b..6e863169f510332f659ac2a24f796ee32730cda7 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
@@ -11,7 +11,7 @@ public final class Versioning {
|
||||
public static String getBukkitVersion() {
|
||||
String result = "Unknown-Version";
|
||||
|
||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.purpurmc.purpur/purpur-api/pom.properties"); // Purpur
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/dev.kaiijumc.kaiiju/kaiiju-api/pom.properties"); // Purpur // Kaiiju
|
||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.purpurmc.purpur/purpur-api/pom.properties"); // Pufferfish // Purpur
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/dev.kaiijumc.kaiiju/kaiiju-api/pom.properties"); // Pufferfish // Purpur // Kaiiju
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index c7c0ed8dfe58c841faf684a1fe228eeda6cd57b7..410ce2dc98c48871d2ddfb0195f2885adc18cba8 100644
|
||||
index 0bcbe1f07ff8e552d2abd6e432af5710005acc04..c6f09e562dd0eb25f3e556627d07758a045d7409 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -227,7 +227,7 @@ public class PurpurConfig {
|
||||
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Kaiiju Configuration
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f935f5f2883
|
||||
index 0000000000000000000000000000000000000000..7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -0,0 +1,193 @@
|
||||
@@ -0,0 +1,195 @@
|
||||
+package dev.kaiijumc.kaiiju;
|
||||
+
|
||||
+import com.google.common.base.Throwables;
|
||||
@@ -27,6 +27,7 @@ index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f93
|
||||
+import java.lang.reflect.InvocationTargetException;
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
@@ -37,7 +38,8 @@ index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f93
|
||||
+ protected static final String HEADER = "This is the main configuration file for Kaiiju.\n"
|
||||
+ + "Some options may impact gameplay, so use with caution.\n"
|
||||
+ + "If you need help or have any questions related to Kaiiju,\n"
|
||||
+ + "Join our Discord server: https://discord.com/invite/qagZRAepb7";
|
||||
+ + "Join our Discord server: https://discord.com/invite/qagZRAepb7\n"
|
||||
+ + "Documentation: https://github.com/KaiijuMC/Kaiiju/wiki/Configuration";
|
||||
+ protected static File CONFIG_FILE;
|
||||
+ public static YamlConfiguration config;
|
||||
+
|
||||
@@ -203,7 +205,6 @@ index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f93
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19
|
||||
@@ -412,175 +413,59 @@ index 0000000000000000000000000000000000000000..0dde8879856f8882f2840b4b8bfb5aa0
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 46858fb57f122033a68aeb4ad3943132a677fb46..92fa3bb708ee2c965a76554268afee4db11f381d 100644
|
||||
index 582467e3419c23446b20d3076fbfce22115250a8..429223724ee5f90cda8d15fa8095a2335a6eacba 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -1,24 +1,21 @@
|
||||
package net.minecraft.server.dedicated;
|
||||
|
||||
-import com.google.common.collect.Lists;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.logging.LogUtils;
|
||||
-import java.io.BufferedReader;
|
||||
+
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
-import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Proxy;
|
||||
-import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
-import java.util.Collections;
|
||||
-import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -58,7 +55,6 @@ import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.io.IoBuilder;
|
||||
import org.bukkit.command.CommandSender;
|
||||
-import co.aikar.timings.MinecraftTimings; // Paper
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
import org.bukkit.craftbukkit.util.Waitable;
|
||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
@@ -227,6 +223,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -227,6 +227,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
}
|
||||
org.purpurmc.purpur.PurpurConfig.registerCommands();
|
||||
// Purpur end
|
||||
+ // Kaiiju start
|
||||
+ try {
|
||||
+ KaiijuConfig.init((java.io.File) options.valueOf("kaiiju-settings"));
|
||||
+ dev.kaiijumc.kaiiju.KaiijuConfig.init((java.io.File) options.valueOf("kaiiju-settings"));
|
||||
+ } catch (Exception e) {
|
||||
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
|
||||
+ return false;
|
||||
+ }
|
||||
+ KaiijuConfig.registerCommands();
|
||||
+ dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands();
|
||||
+ // Kaiiju end
|
||||
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now
|
||||
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
||||
// Paper end
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index a9289072b048095330ea32d7c965e8dda61a36fc..ce8873c47ec10d31d617a10128bed6ff21a24a39 100644
|
||||
index b8001bca2a33ec1e60566948a651400418a6e9e7..666b96835338d4407ef5093668055cbab5c3b6f2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1,10 +1,7 @@
|
||||
package net.minecraft.world.level;
|
||||
|
||||
-import co.aikar.timings.Timing;
|
||||
-import co.aikar.timings.Timings;
|
||||
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
import com.destroystokyo.paper.exception.ServerInternalException;
|
||||
-import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import java.io.IOException;
|
||||
@@ -15,9 +12,10 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import dev.kaiijumc.kaiiju.KaiijuWorldConfig;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
-import net.minecraft.ReportedException;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
@@ -35,15 +33,12 @@ import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
-import net.minecraft.util.AbortableIterationConsumer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
-import net.minecraft.world.entity.boss.EnderDragonPart;
|
||||
-import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -89,17 +84,14 @@ import net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDelayPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDistancePacket;
|
||||
import org.bukkit.Bukkit;
|
||||
-import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CapturedBlockState;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.util.CraftSpawnCategory;
|
||||
-import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.SpawnCategory;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
-import org.bukkit.event.world.GenericGameEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -174,6 +166,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -178,6 +178,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
|
||||
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
|
||||
public final org.purpurmc.purpur.PurpurWorldConfig purpurConfig; // Purpur
|
||||
+ public final KaiijuWorldConfig kaiijuConfig; // Kaiiju
|
||||
|
||||
+ public final dev.kaiijumc.kaiiju.KaiijuWorldConfig kaiijuConfig; // Kaiiju
|
||||
+
|
||||
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
|
||||
public static BlockPos lastPhysicsProblem; // Spigot
|
||||
@@ -330,6 +323,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
private org.spigotmc.TickLimiter entityLimiter;
|
||||
@@ -333,6 +335,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
||||
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
|
||||
this.purpurConfig = new org.purpurmc.purpur.PurpurWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), env); // Purpur
|
||||
+ this.kaiijuConfig = new KaiijuWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), env); // Kaiiju
|
||||
+ this.kaiijuConfig = new dev.kaiijumc.kaiiju.KaiijuWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), env); // Kaiiju
|
||||
this.playerBreedingCooldowns = this.getNewBreedingCooldownCache(); // Purpur
|
||||
this.generator = gen;
|
||||
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index caf1237491649205f7b3c7ea4fe1d31d567bbafe..eacb6fbd753b8448bc8732eec2dc3444b6e93136 100644
|
||||
index c8641ee7cf081b86a461c640ccd70ec4fc39330b..46dc1072e2237e8c9bb4ddbc7d6ca5aab0de4885 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -7,7 +7,6 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
-import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@@ -16,6 +15,7 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -108,7 +108,6 @@ import net.minecraft.world.level.levelgen.PatrolSpawner;
|
||||
import net.minecraft.world.level.levelgen.PhantomSpawner;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||
-import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.saveddata.maps.MapDecoration;
|
||||
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
||||
@@ -1032,6 +1031,7 @@ public final class CraftServer implements Server {
|
||||
@@ -971,6 +971,7 @@ public final class CraftServer implements Server {
|
||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
org.purpurmc.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur
|
||||
+ KaiijuConfig.init((File) console.options.valueOf("kaiiju-settings")); // Kaiiju
|
||||
+ dev.kaiijumc.kaiiju.KaiijuConfig.init((File) console.options.valueOf("kaiiju-settings")); // Kaiiju
|
||||
for (ServerLevel world : this.console.getAllLevels()) {
|
||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
@@ -1048,6 +1048,7 @@ public final class CraftServer implements Server {
|
||||
@@ -987,6 +988,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
world.spigotConfig.init(); // Spigot
|
||||
world.purpurConfig.init(); // Purpur
|
||||
@@ -588,22 +473,22 @@ index caf1237491649205f7b3c7ea4fe1d31d567bbafe..eacb6fbd753b8448bc8732eec2dc3444
|
||||
}
|
||||
|
||||
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
||||
@@ -1064,6 +1065,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1003,6 +1005,7 @@ public final class CraftServer implements Server {
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur
|
||||
+ KaiijuConfig.registerCommands(); // Kaiiju
|
||||
+ dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands(); // Kaiiju
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -2885,6 +2887,13 @@ public final class CraftServer implements Server {
|
||||
@@ -2828,6 +2831,13 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
// Purpur end
|
||||
|
||||
+ // Kaiiju start
|
||||
+ @Override
|
||||
+ public YamlConfiguration getKaiijuConfig() {
|
||||
+ return KaiijuConfig.config;
|
||||
+ return dev.kaiijumc.kaiiju.KaiijuConfig.config;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
@@ -611,10 +496,10 @@ index caf1237491649205f7b3c7ea4fe1d31d567bbafe..eacb6fbd753b8448bc8732eec2dc3444
|
||||
public void restart() {
|
||||
org.spigotmc.RestartCommand.restart();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 576cd8e20982bb20d10213b6c7a229428eec1c2f..190b4bc55d8b1e9983f7b77fd3545a59fa39e6f8 100644
|
||||
index ab05f4151e6ec7404a85ddb3a141ed39d9ed86d7..f722c000ddff9718319d0cb07d18b6f4d9291309 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -180,6 +180,14 @@ public class Main {
|
||||
@@ -187,6 +187,14 @@ public class Main {
|
||||
.describedAs("Yml file");
|
||||
// Purpur end
|
||||
|
||||
|
||||
@@ -5,39 +5,66 @@ Subject: [PATCH] Kaiiju RegionFormat Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index da7e04a93664e20b9187292ddb7c1f935f5f2883..66bbab7ebe1738cd937963b35fad9cdda763fa88 100644
|
||||
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..b86c90cc3601e666998cfa12f44515f605bb53eb 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
+import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -190,4 +191,15 @@ public class KaiijuConfig {
|
||||
@@ -192,4 +192,10 @@ public class KaiijuConfig {
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
+
|
||||
+ public static List<String> regionFormatList = Arrays.asList("ANVIL");
|
||||
+ public static String regionFormatName = "ANVIL";
|
||||
+ public static boolean regionFormatDebug = false;
|
||||
+
|
||||
+ private static void regionFormatSettings() {
|
||||
+ regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..b194f4dbebcbbf5bb4e026a0169e2d24806b46ec 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -4,9 +4,11 @@ import org.apache.commons.lang.BooleanUtils;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
+import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
+import java.util.logging.Level;
|
||||
|
||||
import static dev.kaiijumc.kaiiju.KaiijuConfig.log;
|
||||
|
||||
@@ -122,4 +124,23 @@ public class KaiijuWorldConfig {
|
||||
final Map<String, Object> value = getMap("world-settings." + worldName + "." + path, null);
|
||||
return value.isEmpty() ? fallback : value;
|
||||
}
|
||||
+
|
||||
+ public List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
|
||||
+ public String regionFormatName = "ANVIL";
|
||||
+ public int regionFormatLinearCompressionLevel = 1;
|
||||
+
|
||||
+ private void regionFormatSettings() {
|
||||
+ regionFormatName = getString("region-format.format", regionFormatName).toUpperCase();
|
||||
+ if (!regionFormatList.contains(regionFormatName)) {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Unknown region format in fusion.yml: " + regionFormatName);
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Falling back to ANVIL region file format.");
|
||||
+ log(Level.SEVERE, "Unknown region format in kaiiju.yml: " + regionFormatName);
|
||||
+ log(Level.SEVERE, "Falling back to ANVIL region file format.");
|
||||
+ regionFormatName = "ANVIL";
|
||||
+ }
|
||||
+ regionFormatLinearCompressionLevel = getInt("region-format.linear.compression-level", regionFormatLinearCompressionLevel);
|
||||
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
|
||||
+ log(Level.SEVERE, "Linear region compression level should be between 1 and 22 in kaiiju.yml: " + regionFormatLinearCompressionLevel);
|
||||
+ log(Level.SEVERE, "Falling back to compression level 1.");
|
||||
+ regionFormatLinearCompressionLevel = 1;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 40b4bd2f1a61c2d9a59c9c09b72713401969460b..b9998c288c4e8b6a244722915e44250b6550fd7e 100644
|
||||
index 5f5e9db2cbde552216c8990054b96443f180cb3b..de9a1fb5e43170bf7251b3a0faa9a45eee88f328 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -855,7 +855,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -857,7 +857,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper start - rewrite chunk system
|
||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force, close);
|
||||
if (flush) {
|
||||
@@ -46,7 +73,7 @@ index 40b4bd2f1a61c2d9a59c9c09b72713401969460b..b9998c288c4e8b6a244722915e44250b
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
}
|
||||
@@ -879,7 +879,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -881,7 +881,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
//MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); // Paper - move up
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Copyright xymb@endcrystal.me
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index c6a4c48b14a8c927284720b79b93ee1aa9df7da6..2ea3d2f26d4547ea5094cc63d492ea1406ffbd44 100644
|
||||
index d4f74093cb1bf46eb94e8a47c2fd6e8ee06980f0..9ff2d0cc6d1c6f17f656f0d46dbaf593032844c8 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -13,6 +13,10 @@ dependencies {
|
||||
@@ -16,7 +16,7 @@ index c6a4c48b14a8c927284720b79b93ee1aa9df7da6..2ea3d2f26d4547ea5094cc63d492ea14
|
||||
}
|
||||
// Pufferfish end
|
||||
+ // Kaiiju start - Linear format
|
||||
+ implementation("com.github.luben:zstd-jni:1.5.2-5")
|
||||
+ implementation("com.github.luben:zstd-jni:1.5.4-1")
|
||||
+ implementation("org.lz4:lz4-java:1.8.0")
|
||||
+ // Kaiiju end
|
||||
// Paper start
|
||||
@@ -37,25 +37,12 @@ index f2c27e0ac65be4b75c1d86ef6fd45fdb538d96ac..00724993d0448454d14a47652b039b88
|
||||
|
||||
public static final class InProgressWrite {
|
||||
public long writeCounter;
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index 66bbab7ebe1738cd937963b35fad9cdda763fa88..16ebf32e0c62025958c95216531f72cc418e8d14 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -192,7 +192,7 @@ public class KaiijuConfig {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
- public static List<String> regionFormatList = Arrays.asList("ANVIL");
|
||||
+ public static List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
|
||||
public static String regionFormatName = "ANVIL";
|
||||
|
||||
private static void regionFormatSettings() {
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..70d53d80f474eb80acc93275ad6bf1da98ea8ae7
|
||||
index 0000000000000000000000000000000000000000..249303116d3cfadd078ebf0ae6e44bf99eed6a47
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
|
||||
@@ -0,0 +1,32 @@
|
||||
@@ -0,0 +1,31 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
@@ -69,64 +56,54 @@ index 0000000000000000000000000000000000000000..70d53d80f474eb80acc93275ad6bf1da
|
||||
+import java.util.concurrent.locks.ReentrantLock;
|
||||
+
|
||||
+public interface AbstractRegionFile {
|
||||
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
|
||||
+ void flush() throws IOException;
|
||||
+ void setStatus(int x, int z, ChunkStatus status);
|
||||
+ void clear(ChunkPos pos) throws IOException;
|
||||
+ boolean hasChunk(ChunkPos pos);
|
||||
+ void close() throws IOException;
|
||||
+ void setStatus(int x, int z, ChunkStatus status);
|
||||
+ void setOversized(int x, int z, boolean b) throws IOException;
|
||||
+
|
||||
+ boolean hasChunk(ChunkPos pos);
|
||||
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
|
||||
+ boolean isOversized(int x, int z);
|
||||
+ boolean recalculateHeader() throws IOException;
|
||||
+
|
||||
+ DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException;
|
||||
+ DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException;
|
||||
+ ChunkStatus getStatusIfCached(int x, int z);
|
||||
+
|
||||
+ Path getRegionFile();
|
||||
+ ReentrantLock getFileLock();
|
||||
+
|
||||
+ void setOversized(int x, int z, boolean b) throws IOException;
|
||||
+ CompoundTag getOversizedData(int x, int z) throws IOException;
|
||||
+ boolean isOversized(int x, int z);
|
||||
+ boolean recalculateHeader() throws IOException;
|
||||
+ ChunkStatus getStatusIfCached(int x, int z);
|
||||
+ ReentrantLock getFileLock();
|
||||
+ Path getRegionFile();
|
||||
+}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0b84b1aa4b822bdcb783285e8ea99a4f25dbbaa3
|
||||
index 0000000000000000000000000000000000000000..dcfbabf54b19a4c29d5c95830242c5c26bf2f4aa
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFileFactory.java
|
||||
@@ -0,0 +1,38 @@
|
||||
@@ -0,0 +1,29 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFile;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFileVersion;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.nio.file.Path;
|
||||
+
|
||||
+public class AbstractRegionFileFactory {
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(linearCompression, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ return getAbstractRegionFile(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ return getAbstractRegionFile(linearCompression, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(File file, File directory, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(file.toPath(), directory.toPath(), RegionFileVersion.VERSION_DEFLATE, dsync);
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(linearCompression, file, directory, outputChunkStreamVersion, dsync, false);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(File file, File directory, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ return getAbstractRegionFile(file.toPath(), directory.toPath(), RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(file, directory, outputChunkStreamVersion, dsync, false);
|
||||
+ }
|
||||
+
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ return new LinearRegionFile(file, directory, outputChunkStreamVersion, dsync, canRecalcHeader);
|
||||
+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ if (file.toString().endsWith(".linear")) {
|
||||
+ return new LinearRegionFile(file, linearCompression);
|
||||
+ } else {
|
||||
+ return new RegionFile(file, directory, outputChunkStreamVersion, dsync, canRecalcHeader);
|
||||
+ }
|
||||
@@ -134,10 +111,10 @@ index 0000000000000000000000000000000000000000..0b84b1aa4b822bdcb783285e8ea99a4f
|
||||
+}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52573d1944
|
||||
index 0000000000000000000000000000000000000000..f05d6313012560c32a3ec574b7169ec8e8930282
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||
@@ -0,0 +1,338 @@
|
||||
@@ -0,0 +1,334 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+import com.github.luben.zstd.ZstdInputStream;
|
||||
@@ -150,7 +127,6 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFileVersion;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
@@ -167,13 +143,16 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ private final byte[][] buffer = new byte[32*32][];
|
||||
+ private final int[] bufferUncompressedSize = new int[32*32];
|
||||
+
|
||||
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
|
||||
+ private boolean markedToSave = false;
|
||||
+ private final Object markedToSaveLock = new Object();
|
||||
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
|
||||
+
|
||||
+ private boolean markedToSave = false;
|
||||
+ private boolean close = false;
|
||||
+ public Path regionFile;
|
||||
+
|
||||
+ public final ReentrantLock fileLock = new ReentrantLock(true);
|
||||
+ final byte COMPRESSION_LEVEL = 1;
|
||||
+ public Path regionFile;
|
||||
+
|
||||
+ private final int compressionLevel;
|
||||
+
|
||||
+ public Path getRegionFile() {
|
||||
+ return this.regionFile;
|
||||
@@ -183,13 +162,14 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ return this.fileLock;
|
||||
+ }
|
||||
+
|
||||
+ public LinearRegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
||||
+ this.regionFile = file;
|
||||
+ this.compressionLevel = compression;
|
||||
+ File regionFile = new File(this.regionFile.toString());
|
||||
+
|
||||
+ LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||
+
|
||||
+ for (int i = 0 ; i < 32 * 32 ; i++)
|
||||
+ for (int i = 0; i < 32 * 32; i++)
|
||||
+ this.bufferUncompressedSize[i] = 0;
|
||||
+
|
||||
+ if(regionFile.canRead()) {
|
||||
@@ -204,28 +184,21 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+
|
||||
+ long superBlock = rawDataStream.readLong();
|
||||
+
|
||||
+ if (superBlock != SUPERBLOCK) {
|
||||
+ System.out.println(file.toString());
|
||||
+ System.out.println("SUPERBLOCK INVALID!");
|
||||
+ return;
|
||||
+ }
|
||||
+ if (superBlock != SUPERBLOCK)
|
||||
+ throw new RuntimeException("Superblock invalid: " + superBlock + " file " + file);
|
||||
+
|
||||
+ byte version = rawDataStream.readByte();
|
||||
+
|
||||
+ if (version != VERSION) {
|
||||
+ System.out.println(file.toString());
|
||||
+ System.out.println("VERSION INVALID!");
|
||||
+ return;
|
||||
+ }
|
||||
+ if (version != VERSION)
|
||||
+ throw new RuntimeException("Version invalid: " + version + " file " + file);
|
||||
+
|
||||
+ rawDataStream.readLong(); // newestTimestamp
|
||||
+ rawDataStream.readByte(); // Compression level
|
||||
+ rawDataStream.readShort(); // Chunk count
|
||||
+ int dataCount = rawDataStream.readInt();
|
||||
+
|
||||
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE) {
|
||||
+ throw new IOException("File length invalid " + this.regionFile + " " + String.valueOf(fileLength) + " " + String.valueOf(HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||
+ }
|
||||
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE)
|
||||
+ throw new IOException("File length invalid " + this.regionFile + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||
+
|
||||
+ rawDataStream.readLong(); // Data Hash
|
||||
+ byte[] rawCompressed = new byte[dataCount];
|
||||
@@ -319,7 +292,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ FileOutputStream fileStream = new FileOutputStream(tempFile);
|
||||
+
|
||||
+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream();
|
||||
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, COMPRESSION_LEVEL);
|
||||
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel);
|
||||
+ zstdStream.setChecksum(true);
|
||||
+ DataOutputStream zstdDataStream = new DataOutputStream(zstdStream);
|
||||
+ DataOutputStream dataStream = new DataOutputStream(fileStream);
|
||||
@@ -327,11 +300,11 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ dataStream.writeLong(SUPERBLOCK);
|
||||
+ dataStream.writeByte(VERSION);
|
||||
+ dataStream.writeLong(timestamp);
|
||||
+ dataStream.writeByte(COMPRESSION_LEVEL);
|
||||
+ dataStream.writeByte(this.compressionLevel);
|
||||
+
|
||||
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||
+
|
||||
+ ArrayList<byte[]> byteBuffers = new ArrayList<byte[]>();
|
||||
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
|
||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
||||
+ if(this.bufferUncompressedSize[i] != 0) {
|
||||
+ chunkCount += 1;
|
||||
@@ -386,13 +359,13 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ this.buffer[getChunkIndex(pos.x, pos.z)] = b;
|
||||
+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize;
|
||||
+ } catch (IOException e) {
|
||||
+ LOGGER.error("Chunk write IOException " + e.toString() + " " + this.regionFile);
|
||||
+ LOGGER.error("Chunk write IOException " + e + " " + this.regionFile);
|
||||
+ }
|
||||
+
|
||||
+ markToSave();
|
||||
+ }
|
||||
+
|
||||
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException {
|
||||
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) {
|
||||
+ return new DataOutputStream(new BufferedOutputStream(new LinearRegionFile.ChunkBuffer(pos)));
|
||||
+ }
|
||||
+
|
||||
@@ -424,7 +397,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException {
|
||||
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
|
||||
+ if(this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
|
||||
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||
+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]];
|
||||
@@ -454,7 +427,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ try {
|
||||
+ flush();
|
||||
+ } catch(IOException e) {
|
||||
+ throw new IOException("Region flush IOException " + e.toString() + " " + this.regionFile);
|
||||
+ throw new IOException("Region flush IOException " + e + " " + this.regionFile);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -462,7 +435,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ return (x & 31) + (z & 31) * 32;
|
||||
+ }
|
||||
+
|
||||
+ public boolean recalculateHeader() throws IOException {
|
||||
+ public boolean recalculateHeader() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
@@ -477,7 +450,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a7bf09d2a 100644
|
||||
index a08cde4eefe879adcee7c4118bc38f98c5097ed0..1cfc20b7496f93aff1d6c2387dc5bb8bacab8dc8 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
@@ -811,7 +811,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -543,32 +516,49 @@ index a08cde4eefe879adcee7c4118bc38f98c5097ed0..77ce70697f2a634927fd02f2a103c91a
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1287,6 +1287,12 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
} catch (final ThreadDeath thr) {
|
||||
throw thr;
|
||||
} catch (final Throwable thr) {
|
||||
+ // Kaiiju start - Linear region format
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ failedWrite = thr instanceof IOException;
|
||||
+ LOGGER.error("Failed to write chunk data for task: " + this.toString(), thr);
|
||||
+ } else {
|
||||
+ // Kaiiju end
|
||||
if (thr instanceof RegionFileStorage.RegionFileSizeException) {
|
||||
final int maxSize = RegionFile.MAX_CHUNK_SIZE / (1024 * 1024);
|
||||
LOGGER.error("Chunk at (" + this.chunkX + "," + this.chunkZ + ") in '" + this.world.getWorld().getName() + "' exceeds max size of " + maxSize + "MiB, it has been deleted from disk.");
|
||||
@@ -1294,6 +1300,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
failedWrite = thr instanceof IOException;
|
||||
LOGGER.error("Failed to write chunk data for task: " + this.toString(), thr);
|
||||
}
|
||||
+ } // Kaiiju
|
||||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
index 513833c2ea23df5b079d157bc5cb89d5c9754c0b..a62a1b281bd0b6ad7d59b45b9470d84f496f6539 100644
|
||||
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
@@ -83,9 +83,13 @@ public class ThreadedWorldUpgrader {
|
||||
}
|
||||
LOGGER.info("Found " + regionFiles.length + " regionfiles to convert");
|
||||
LOGGER.info("Starting conversion now for world " + this.worldName);
|
||||
-
|
||||
+ // Kaiiju start
|
||||
+ String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
||||
+ int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||
+ LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
|
||||
+ // Kaiiju end
|
||||
final WorldInfo info = new WorldInfo(() -> worldPersistentData,
|
||||
- new ChunkStorage(regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey);
|
||||
+ new ChunkStorage(formatName, linearCompression, regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey); // Kaiiju
|
||||
|
||||
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
||||
|
||||
final boolean finalFailWrite = failedWrite;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..2158c576aa47ef618b7602c2f4e351b7beb023b3 100644
|
||||
index 5d330c938aa0d707460b740ecf5c51d001c89c49..86dc7e23fb53f6ba8baff1aa0309af78b248844b 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -950,13 +950,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -294,7 +294,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper end
|
||||
|
||||
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
||||
- super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
|
||||
+ super(world.getLevel().kaiijuConfig.regionFormatName, world.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
|
||||
// Paper - rewrite chunk system
|
||||
this.tickingGenerated = new AtomicInteger();
|
||||
this.playerMap = new PlayerMap();
|
||||
@@ -339,7 +339,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.lightEngine = new ThreadedLevelLightEngine(chunkProvider, this, this.level.dimensionType().hasSkyLight(), null, null); // Paper - rewrite chunk system
|
||||
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
||||
this.overworldDataStorage = persistentStateManagerFactory;
|
||||
- this.poiManager = new PoiManager(path.resolve("poi"), dataFixer, dsync, iregistrycustom, world);
|
||||
+ this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||
this.setViewDistance(viewDistance);
|
||||
// Paper start
|
||||
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
||||
@@ -953,13 +953,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
// Paper start - chunk status cache "api"
|
||||
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
||||
@@ -584,7 +574,7 @@ index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..2158c576aa47ef618b7602c2f4e351b7
|
||||
|
||||
if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
|
||||
return null;
|
||||
@@ -974,7 +974,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -977,7 +977,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException {
|
||||
@@ -593,50 +583,115 @@ index 75965afd7b4bed23a5ecf618c7f91ff5e7ffd92f..2158c576aa47ef618b7602c2f4e351b7
|
||||
|
||||
regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkSerializer.getStatus(compound));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 69ba84de4880a579c400b6daefdb98b44e9e28e8..83126ee9d737cf695c34e239c204fe8c4d02c243 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -388,9 +388,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
private final EntityRegionFileStorage entityStorage;
|
||||
|
||||
private static final class EntityRegionFileStorage extends net.minecraft.world.level.chunk.storage.RegionFileStorage {
|
||||
-
|
||||
- public EntityRegionFileStorage(Path directory, boolean dsync) {
|
||||
- super(directory, dsync);
|
||||
+ public EntityRegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
||||
+ super(format, linearCompression, directory, dsync); // Kaiiju
|
||||
}
|
||||
|
||||
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
|
||||
@@ -583,7 +582,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// CraftBukkit end
|
||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||
- this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
|
||||
+ this.entityStorage = new EntityRegionFileStorage(this.getLevel().kaiijuConfig.regionFormatName, this.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); // Kaiiju
|
||||
|
||||
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
|
||||
StructureTemplateManager structuretemplatemanager = minecraftserver.getStructureManager();
|
||||
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
index 759b125cc1251b9b4f1f443c9f70c482ef5b32f8..aca60733c87f7f95b5719ded24eb8cf697f9d83e 100644
|
||||
index e0bfeebeaac1aaea64bc07cdfdf7790e3e43ca7b..469802b9c454c5e98c0a55ba89559d9d8ba0c4c0 100644
|
||||
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
@@ -61,10 +61,17 @@ public class WorldUpgrader {
|
||||
@@ -61,7 +61,7 @@ public class WorldUpgrader {
|
||||
private volatile int skipped;
|
||||
private final Object2FloatMap<ResourceKey<LevelStem>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy())); // CraftBukkit
|
||||
private volatile Component status = Component.translatable("optimizeWorld.stage.counting");
|
||||
- public static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||
+ public static Pattern REGEX; // Kaiiju
|
||||
+ public static Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // Kaiiju
|
||||
private final DimensionDataStorage overworldDataStorage;
|
||||
|
||||
public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, Registry<LevelStem> dimensionOptionsRegistry, boolean eraseCache) {
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ this.REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.linear$");
|
||||
+ } else {
|
||||
+ this.REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
this.dimensions = dimensionOptionsRegistry;
|
||||
this.levels = (Set) dimensionOptionsRegistry.registryKeySet().stream().collect(Collectors.toUnmodifiableSet()); // CraftBukkit
|
||||
this.eraseCache = eraseCache;
|
||||
@@ -235,6 +242,11 @@ public class WorldUpgrader {
|
||||
@@ -115,8 +115,12 @@ public class WorldUpgrader {
|
||||
while (iterator1.hasNext()) {
|
||||
ResourceKey<LevelStem> resourcekey1 = (ResourceKey) iterator1.next(); // CraftBukkit
|
||||
Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit
|
||||
-
|
||||
- builder1.put(resourcekey1, new ChunkStorage(path.resolve("region"), this.dataFixer, true));
|
||||
+ // Kaiiju start
|
||||
+ String worldName = this.levelStorage.getLevelId();
|
||||
+ String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
||||
+ int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||
+ builder1.put(resourcekey1, new ChunkStorage(formatName, linearCompression, path.resolve("region"), this.dataFixer, true));
|
||||
+ // Kaiiju end
|
||||
}
|
||||
|
||||
ImmutableMap<ResourceKey<LevelStem>, ChunkStorage> immutablemap1 = builder1.build(); // CraftBukkit
|
||||
@@ -235,7 +239,7 @@ public class WorldUpgrader {
|
||||
File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit
|
||||
File file1 = new File(file, "region");
|
||||
File[] afile = file1.listFiles((file2, s) -> {
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ return s.endsWith(".linear");
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return s.endsWith(".mca");
|
||||
- return s.endsWith(".mca");
|
||||
+ return s.endsWith(".mca") || s.endsWith(".linear"); // Kaiiju
|
||||
});
|
||||
|
||||
@@ -254,7 +266,7 @@ public class WorldUpgrader {
|
||||
if (afile == null) {
|
||||
@@ -254,7 +258,11 @@ public class WorldUpgrader {
|
||||
int l = Integer.parseInt(matcher.group(2)) << 5;
|
||||
|
||||
try {
|
||||
- RegionFile regionfile = new RegionFile(file2.toPath(), file1.toPath(), true);
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(file2.toPath(), file1.toPath(), true); // Kaiiju
|
||||
+ // Kaiiju start
|
||||
+ String worldName = this.levelStorage.getLevelId();
|
||||
+ int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(linearCompression, file2.toPath(), file1.toPath(), true);
|
||||
+ // Kaiiju end
|
||||
|
||||
try {
|
||||
for (int i1 = 0; i1 < 32; ++i1) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
index 8950b220b9a3512cd4667beb7bdec0e82e07edc6..71b38521fd2039bb2ddfdc5dc89341282869ce30 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
|
||||
@@ -57,8 +57,8 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
||||
// Paper end - rewrite chunk system
|
||||
|
||||
|
||||
- public PoiManager(Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) {
|
||||
- super(path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world);
|
||||
+ public PoiManager(String formatName, int linearCompression, Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) { // Kaiiju
|
||||
+ super(formatName, linearCompression, path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world); // Kaiiju
|
||||
this.world = (net.minecraft.server.level.ServerLevel)world; // Paper - rewrite chunk system
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
index 29facbdcbad17ce38bf785f7f3f8346d81cbc32f..52c2e0fe73a5af18535a2b0b9a506919e3f93003 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
@@ -37,11 +37,12 @@ public class ChunkStorage implements AutoCloseable {
|
||||
public final RegionFileStorage regionFileCache;
|
||||
// Paper end - async chunk loading
|
||||
|
||||
- public ChunkStorage(Path directory, DataFixer dataFixer, boolean dsync) {
|
||||
+ public ChunkStorage(String format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
||||
this.fixerUpper = dataFixer;
|
||||
+
|
||||
// Paper start - async chunk io
|
||||
// remove IO worker
|
||||
- this.regionFileCache = new RegionFileStorage(directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
+ this.regionFileCache = new RegionFileStorage(format, linearCompression, directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
// Paper end - async chunk io
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788ecafb8e9d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -699,39 +754,49 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788e
|
||||
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
|
||||
return NbtIo.read((java.io.DataInput) out);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da747cf30c 100644
|
||||
index bd502ca721de0cab438d995efa00ad0554c0d2fe..254bc0d853770ef36ff10bce92be37f0300335fb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -21,8 +21,9 @@ import net.minecraft.world.level.ChunkPos;
|
||||
public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -22,17 +22,25 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
public static final String ANVIL_EXTENSION = ".mca";
|
||||
+ public static final String LINEAR_EXTENSION = ".linear"; // Kaiiju
|
||||
private static final int MAX_CACHE_SIZE = 256;
|
||||
- public final Long2ObjectLinkedOpenHashMap<RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap();
|
||||
+ public final Long2ObjectLinkedOpenHashMap<dev.kaiijumc.kaiiju.region.AbstractRegionFile> regionCache = new Long2ObjectLinkedOpenHashMap(); // Kaiiju
|
||||
private final Path folder;
|
||||
private final boolean sync;
|
||||
+ // Kaiiju start - Per world chunk format
|
||||
+ public final String format;
|
||||
+ public final int linearCompression;
|
||||
+ // Kaiiju end
|
||||
|
||||
@@ -42,9 +43,17 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
private final boolean isChunkData; // Paper
|
||||
|
||||
- protected RegionFileStorage(Path directory, boolean dsync) { // Paper - protected constructor
|
||||
+ protected RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Paper - protected constructor
|
||||
// Paper start - add isChunkData param
|
||||
- this(directory, dsync, false);
|
||||
+ this(format, linearCompression, directory, dsync, false);
|
||||
}
|
||||
- RegionFileStorage(Path directory, boolean dsync, boolean isChunkData) {
|
||||
+ RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
||||
+ // Kaiiju start
|
||||
+ this.format = format;
|
||||
+ this.linearCompression = linearCompression;
|
||||
+ // Kaiiju end
|
||||
this.isChunkData = isChunkData;
|
||||
// Paper end - add isChunkData param
|
||||
this.folder = directory;
|
||||
@@ -42,7 +50,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
// Paper start
|
||||
public static @Nullable ChunkPos getRegionFileCoordinates(Path file) {
|
||||
String fileName = file.getFileName().toString();
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".linear")) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ } else {
|
||||
+ // Kaiiju end
|
||||
if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
|
||||
- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
|
||||
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".mca") || !fileName.endsWith(".linear")) { // Kaiiju
|
||||
return null;
|
||||
}
|
||||
+ } // Kaiiju
|
||||
|
||||
String[] split = fileName.split("\\.");
|
||||
|
||||
@@ -62,49 +71,57 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -62,49 +70,68 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -777,18 +842,30 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
Path path = this.folder;
|
||||
int j = chunkcoordintpair.getRegionX();
|
||||
- Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change
|
||||
+ // Kaiiju start
|
||||
- if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
|
||||
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
|
||||
+ // Kaiiju start - Polyglot
|
||||
+ //Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change
|
||||
+ Path path1;
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatName.equals("LINEAR")) {
|
||||
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
|
||||
+ if (existingOnly) {
|
||||
+ Path anvil = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||
+ Path linear = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
|
||||
+ if (java.nio.file.Files.exists(anvil)) path1 = anvil;
|
||||
+ else if (java.nio.file.Files.exists(linear)) path1 = linear;
|
||||
+ else return null;
|
||||
+ } else {
|
||||
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||
+ String extension = switch (this.format) {
|
||||
+ case "LINEAR" -> "linear";
|
||||
+ default -> "mca";
|
||||
+ };
|
||||
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension);
|
||||
+ }
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatDebug)
|
||||
+ org.bukkit.Bukkit.getLogger().info("[Region File Storage] Opening file " + path1 + " with format " + this.format + " (existingOnly = " + existingOnly + ")");
|
||||
+ //if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
|
||||
+ // Kaiiju end
|
||||
if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
|
||||
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile1 = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Kaiiju
|
||||
+
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile1 = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(this.linearCompression, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Kaiiju
|
||||
|
||||
this.regionCache.putAndMoveToFirst(i, regionfile1);
|
||||
// Paper start
|
||||
@@ -799,7 +876,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
}
|
||||
// Paper end
|
||||
return regionfile1;
|
||||
@@ -132,7 +149,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -132,7 +159,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
|
||||
|
||||
@@ -808,7 +885,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
synchronized (regionfile) {
|
||||
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
|
||||
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
|
||||
@@ -179,14 +196,14 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -179,14 +206,14 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@Nullable
|
||||
public CompoundTag read(ChunkPos pos) throws IOException {
|
||||
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
@@ -825,7 +902,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
// We add the regionfile parameter to avoid the potential deadlock (on fileLock) if we went back to obtain a regionfile
|
||||
// if we decide to re-read
|
||||
// Paper end
|
||||
@@ -196,7 +213,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -196,7 +223,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
// Paper start
|
||||
if (regionfile.isOversized(pos.x, pos.z)) {
|
||||
@@ -834,7 +911,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
return readOversizedChunk(regionfile, pos);
|
||||
}
|
||||
// Paper end
|
||||
@@ -210,12 +227,12 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -210,12 +237,12 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
if (this.isChunkData) {
|
||||
ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound);
|
||||
if (!chunkPos.equals(pos)) {
|
||||
@@ -850,7 +927,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -249,13 +266,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -249,13 +276,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
return nbttagcompound;
|
||||
} finally { // Paper start
|
||||
@@ -866,7 +943,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
if (regionfile == null) {
|
||||
return;
|
||||
}
|
||||
@@ -285,7 +302,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -285,7 +312,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
|
||||
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
|
||||
@@ -875,7 +952,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
if (nbt == null && regionfile == null) {
|
||||
return;
|
||||
}
|
||||
@@ -335,7 +352,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -335,7 +362,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
// Paper end
|
||||
} finally { // Paper start
|
||||
@@ -884,7 +961,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
} // Paper end
|
||||
}
|
||||
|
||||
@@ -344,7 +361,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -344,7 +371,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -893,7 +970,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
|
||||
try {
|
||||
regionfile.close();
|
||||
@@ -360,7 +377,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -360,7 +387,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -902,8 +979,23 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
|
||||
|
||||
regionfile.flush();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
index 5561b8499a0503b850974b1dc309edfb80219549..414aa3ae00c2d28e754235e3e93b6b623d4fd180 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||
@@ -47,8 +47,8 @@ public class SectionStorage<R> extends RegionFileStorage implements AutoCloseabl
|
||||
public final RegistryAccess registryAccess; // Paper - rewrite chunk system
|
||||
protected final LevelHeightAccessor levelHeightAccessor;
|
||||
|
||||
- public SectionStorage(Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) {
|
||||
- super(path, dsync); // Paper - remove mojang I/O thread
|
||||
+ public SectionStorage(String format, int linearCompression, Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) { // Kaiiju
|
||||
+ super(format, linearCompression, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
|
||||
this.codec = codecFactory;
|
||||
this.factory = factory;
|
||||
this.fixerUpper = dataFixer;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index b17bc6482d2bd97d2e48d3967dea72605cf13164..2a13629ffb60dc60706da446e6dc7f3683d0410b 100644
|
||||
index c6a3b59c65466f9f2b16cefe0059a6e5dd84044c..e9cca721fb065fe6ac715bbeef65343f528d0a42 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -552,7 +552,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@@ -5,16 +5,15 @@ Subject: [PATCH] Kaiiju Lobotomize Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..ac4440f8d2bd30e3e074ef797d5138b64996fcbb 100644
|
||||
index b194f4dbebcbbf5bb4e026a0169e2d24806b46ec..907fdfb368c87bfe7b4374bb0b5f49d5ff095339 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;
|
||||
}
|
||||
}
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+
|
||||
+ private void lobotomizeSettings() {
|
||||
+ }
|
||||
+}
|
||||
}
|
||||
\ No newline at end of file
|
||||
|
||||
@@ -7,31 +7,34 @@ Inspired by "Lobotomized animals" by @KioProject123
|
||||
Checks might be a nuisance to performance.
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index ac4440f8d2bd30e3e074ef797d5138b64996fcbb..dbbba258dbdc465b89c71508d76c5c596fd03bea 100644
|
||||
index 907fdfb368c87bfe7b4374bb0b5f49d5ff095339..b99b438b92587f23c77c5321d5d23e76dc5450de 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -123,6 +123,15 @@ public class KaiijuWorldConfig {
|
||||
return value.isEmpty() ? fallback : value;
|
||||
@@ -144,6 +144,17 @@ public class KaiijuWorldConfig {
|
||||
}
|
||||
}
|
||||
|
||||
+ public boolean lobotomizeAnimalEnabled = false;
|
||||
+ public int lobotomizeAnimalCheckInterval = 100;
|
||||
+ public boolean lobotomizeAnimalCheckCanJump = true;
|
||||
+ public boolean lobotomizeAnimalLookAtPlayer = false;
|
||||
+ public boolean lobotomizeAnimalFloat = true;
|
||||
+
|
||||
private void lobotomizeSettings() {
|
||||
+ lobotomizeAnimalEnabled = getBoolean("lobotomize.animal.enabled", lobotomizeAnimalEnabled);
|
||||
+ lobotomizeAnimalCheckInterval = getInt("lobotomize.animal.check-interval", lobotomizeAnimalCheckInterval);
|
||||
+ lobotomizeAnimalCheckCanJump = getBoolean("lobotomize.animal.check-can-jump", lobotomizeAnimalCheckCanJump);
|
||||
+ lobotomizeAnimalLookAtPlayer = getBoolean("lobotomize.animal.look-at-player", lobotomizeAnimalLookAtPlayer);
|
||||
+ lobotomizeAnimalFloat = getBoolean("lobotomize.animal.float", lobotomizeAnimalFloat);
|
||||
}
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/entity/Lobotomized.java b/src/main/java/dev/kaiijumc/kaiiju/entity/Lobotomized.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8912f25e94d5e7510d965aa02b73c87e0b75fb51
|
||||
index 0000000000000000000000000000000000000000..14f085e75295882f52634622b40676295cd78d5f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/entity/Lobotomized.java
|
||||
@@ -0,0 +1,56 @@
|
||||
@@ -0,0 +1,73 @@
|
||||
+package dev.kaiijumc.kaiiju.entity;
|
||||
+
|
||||
+import net.minecraft.core.BlockPos;
|
||||
@@ -52,15 +55,15 @@ index 0000000000000000000000000000000000000000..8912f25e94d5e7510d965aa02b73c87e
|
||||
+ this.isLobotomized = b;
|
||||
+ }
|
||||
+
|
||||
+ public boolean checkLobotomized(LivingEntity livingEntity) {
|
||||
+ Level level = livingEntity.getLevel();
|
||||
+ public boolean checkLobotomized(LivingEntity entity) {
|
||||
+ Level level = entity.getLevel();
|
||||
+ int interval = level.kaiijuConfig.lobotomizeAnimalCheckInterval;
|
||||
+ if (this.notLobotomizedCount > 3) {
|
||||
+ // check half as often if not lobotomized for the last 3+ consecutive checks
|
||||
+ interval *= 2;
|
||||
+ }
|
||||
+ if ((livingEntity.getId() + livingEntity.tickCount) % interval == 0) {
|
||||
+ this.isLobotomized = livingEntity.isOnGround() && !canTravelFrom(new BlockPos(livingEntity.getX(), livingEntity.getY() + 0.5D, livingEntity.getZ()), level, livingEntity.getBbHeight() <= 1.0F);
|
||||
+ if ((entity.getId() + entity.tickCount) % interval == 0) {
|
||||
+ this.isLobotomized = entity.isOnGround() && !canTravelFrom(entity, level, entity.getBbHeight() <= 1.0F);
|
||||
+
|
||||
+ if (this.isLobotomized) {
|
||||
+ this.notLobotomizedCount = 0;
|
||||
@@ -71,28 +74,45 @@ index 0000000000000000000000000000000000000000..8912f25e94d5e7510d965aa02b73c87e
|
||||
+ return this.isLobotomized;
|
||||
+ }
|
||||
+
|
||||
+ private boolean canTravelFrom(BlockPos pos, Level level, boolean ignoreTop) {
|
||||
+ return canTravelTo(pos.east(), level, ignoreTop)
|
||||
+ || canTravelTo(pos.west(), level, ignoreTop)
|
||||
+ || canTravelTo(pos.north(), level, ignoreTop)
|
||||
+ || canTravelTo(pos.south(), level, ignoreTop);
|
||||
+ private boolean canTravelFrom(LivingEntity entity, Level level, boolean ignoreTop) {
|
||||
+ BlockPos pos = new BlockPos(entity.getBlockX(), (int) (entity.getY() + 0.5D), entity.getBlockZ());
|
||||
+ return canTravelTo(entity, pos.east(), level, ignoreTop)
|
||||
+ || canTravelTo(entity, pos.west(), level, ignoreTop)
|
||||
+ || canTravelTo(entity, pos.north(), level, ignoreTop)
|
||||
+ || canTravelTo(entity, pos.south(), level, ignoreTop);
|
||||
+ }
|
||||
+
|
||||
+ private boolean canTravelTo(BlockPos pos, Level level, boolean ignoreTop) {
|
||||
+ private boolean canTravelTo(LivingEntity entity, BlockPos pos, Level level, boolean ignoreTop) {
|
||||
+ BlockState top;
|
||||
+ // Check if mob can jump over block
|
||||
+ if (level.kaiijuConfig.lobotomizeAnimalCheckCanJump && canJump(entity, level, ignoreTop)) {
|
||||
+ top = level.getBlockStateIfLoaded(pos.above());
|
||||
+ if (top == null) return false;
|
||||
+ if (top.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND)) {
|
||||
+ if (ignoreTop) return true;
|
||||
+ net.minecraft.world.level.block.state.BlockState above = level.getBlockState(pos.above(2));
|
||||
+ if (above.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND)) return true;
|
||||
+ }
|
||||
+ }
|
||||
+ BlockState bottom = level.getBlockStateIfLoaded(pos);
|
||||
+ if (bottom == null) return false; // Chunk not loaded
|
||||
+ if (!bottom.isPathfindable(level, pos, PathComputationType.LAND)) return false;
|
||||
+ if (ignoreTop) return true;
|
||||
+ BlockState top = level.getBlockState(pos.above());
|
||||
+ if (!top.isPathfindable(level, pos, PathComputationType.LAND)) return false;
|
||||
+ return true;
|
||||
+ top = level.getBlockState(pos.above());
|
||||
+ return top.isPathfindable(level, pos, PathComputationType.LAND);
|
||||
+ }
|
||||
+
|
||||
+ private boolean canJump(LivingEntity entity, Level level, boolean ignoreTop) {
|
||||
+ BlockPos pos = new BlockPos(entity.getBlockX(), (int) (entity.getY() + 2.5D), entity.getBlockZ());
|
||||
+ net.minecraft.world.level.block.Block above = level.getBlockIfLoaded(pos);
|
||||
+ return !above.hasCollision;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index b2e4b5c463ceb19356da18e7fc52d20801b674cd..32ea0b1542ef374db3290e01978d7965715b9de6 100644
|
||||
index 8d7c33e16f9eaec2120c5aad75172ff656d1bd17..52b09f9ff2a7bc36ae742a53c5141d7de03fb848 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -308,6 +308,8 @@ public abstract class LivingEntity extends Entity {
|
||||
@@ -303,6 +303,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.brain = this.makeBrain(new Dynamic(dynamicopsnbt, (Tag) dynamicopsnbt.createMap((Map) ImmutableMap.of(dynamicopsnbt.createString("memories"), (Tag) dynamicopsnbt.emptyMap()))));
|
||||
}
|
||||
|
||||
@@ -206,10 +226,10 @@ index 2cbc9adc8e417def48be03d08174a5833068ec65..3234d5bf3b9ae01dbe8e26a0a3f21ff8
|
||||
if (this.mob.distanceToSqr((Entity) this.player) < 36.0D) {
|
||||
if (this.player.distanceToSqr(this.px, this.py, this.pz) > 0.010000000000000002D) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
index 2f2d9bb31194618ef5bba39cd1cbe7c4919e82c5..0d8f1f063b76357374022e4496ce0646757b150e 100644
|
||||
index 6d127ed3da899851ca95b2be6792e2abca1aca12..31f98654389dc030b70ab38530d4a7be31686279 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
@@ -197,6 +197,7 @@ public abstract class PathNavigation {
|
||||
@@ -198,6 +198,7 @@ public abstract class PathNavigation {
|
||||
// Paper end
|
||||
|
||||
public boolean moveTo(Entity entity, double speed) {
|
||||
@@ -217,7 +237,7 @@ index 2f2d9bb31194618ef5bba39cd1cbe7c4919e82c5..0d8f1f063b76357374022e4496ce0646
|
||||
// Paper start - Pathfinding optimizations
|
||||
if (this.pathfindFailures > 10 && this.path == null && net.minecraft.server.MinecraftServer.currentTick < this.lastFailure + 40) {
|
||||
return false;
|
||||
@@ -217,6 +218,7 @@ public abstract class PathNavigation {
|
||||
@@ -218,6 +219,7 @@ public abstract class PathNavigation {
|
||||
}
|
||||
|
||||
public boolean moveTo(@Nullable Path path, double speed) {
|
||||
@@ -301,10 +321,10 @@ index 2ac88f06ebb79e515cd9934ac1e3e2c8003d9e3c..d89c0db4c4173d8558dc4f8b15ddb581
|
||||
|
||||
public static boolean checkAnimalSpawnRules(EntityType<? extends Animal> type, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, RandomSource random) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
index 87bd7991a81a2e30ecfccb60e614d7f13acd3744..1c2db953155498606f1e052580e7aa9ca846a53c 100644
|
||||
index d47dc0c3fe8c2b80d7b7eb828a12af6eb32145e4..bb3a7efd11731d518cf8ef29f25c855bbbba0568 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -1047,6 +1047,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@@ -1042,6 +1042,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canBeeUse() {
|
||||
@@ -312,7 +332,7 @@ index 87bd7991a81a2e30ecfccb60e614d7f13acd3744..1c2db953155498606f1e052580e7aa9c
|
||||
return Bee.this.remainingCooldownBeforeLocatingNewHive == 0 && !Bee.this.hasHive() && Bee.this.wantsToEnterHive();
|
||||
}
|
||||
|
||||
@@ -1113,6 +1114,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@@ -1108,6 +1109,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canBeeUse() {
|
||||
@@ -320,7 +340,7 @@ index 87bd7991a81a2e30ecfccb60e614d7f13acd3744..1c2db953155498606f1e052580e7aa9c
|
||||
return Bee.this.hivePos != null && !Bee.this.hasRestriction() && Bee.this.wantsToEnterHive() && !this.hasReachedTarget(Bee.this.hivePos) && Bee.this.level.getBlockState(Bee.this.hivePos).is(BlockTags.BEEHIVES);
|
||||
}
|
||||
|
||||
@@ -1229,6 +1231,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@@ -1224,6 +1226,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canBeeUse() {
|
||||
@@ -328,7 +348,7 @@ index 87bd7991a81a2e30ecfccb60e614d7f13acd3744..1c2db953155498606f1e052580e7aa9c
|
||||
return Bee.this.savedFlowerPos != null && !Bee.this.hasRestriction() && this.wantsToGoToKnownFlower() && Bee.this.isFlowerValid(Bee.this.savedFlowerPos) && !Bee.this.closerThan(Bee.this.savedFlowerPos, 2);
|
||||
}
|
||||
|
||||
@@ -1281,6 +1284,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@@ -1276,6 +1279,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canBeeUse() {
|
||||
|
||||
@@ -5,33 +5,37 @@ Subject: [PATCH] Kaiiju Lobotomize Villager
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
index dbbba258dbdc465b89c71508d76c5c596fd03bea..a213a3c447cd69b5dd88eefd48c2caa6d19f5abc 100644
|
||||
index b99b438b92587f23c77c5321d5d23e76dc5450de..366948e447c0729389ec53286236a82cb57e97a2 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||
@@ -127,11 +127,21 @@ public class KaiijuWorldConfig {
|
||||
public int lobotomizeAnimalCheckInterval = 100;
|
||||
@@ -149,6 +149,12 @@ public class KaiijuWorldConfig {
|
||||
public boolean lobotomizeAnimalCheckCanJump = true;
|
||||
public boolean lobotomizeAnimalLookAtPlayer = false;
|
||||
public boolean lobotomizeAnimalFloat = true;
|
||||
+ public boolean lobotomizeVillagerEnabled = false;
|
||||
+ public int lobotomizeVillagerCheckInterval = 100;
|
||||
+ public boolean lobotomizeVillagerCheckCanJump = true;
|
||||
+ public boolean lobotomizeVillagerCheckOnBed = true;
|
||||
+ public boolean lobotomizeVillagerCheckActionBlock = true;
|
||||
+ public boolean lobotomizeVillagerCheckJobSite = true;
|
||||
+ public boolean lobotomizeVillagerCheckBedNearby = true;
|
||||
|
||||
private void lobotomizeSettings() {
|
||||
lobotomizeAnimalEnabled = getBoolean("lobotomize.animal.enabled", lobotomizeAnimalEnabled);
|
||||
lobotomizeAnimalCheckInterval = getInt("lobotomize.animal.check-interval", lobotomizeAnimalCheckInterval);
|
||||
@@ -156,5 +162,11 @@ public class KaiijuWorldConfig {
|
||||
lobotomizeAnimalCheckCanJump = getBoolean("lobotomize.animal.check-can-jump", lobotomizeAnimalCheckCanJump);
|
||||
lobotomizeAnimalLookAtPlayer = getBoolean("lobotomize.animal.look-at-player", lobotomizeAnimalLookAtPlayer);
|
||||
lobotomizeAnimalFloat = getBoolean("lobotomize.animal.float", lobotomizeAnimalFloat);
|
||||
+ lobotomizeVillagerEnabled = getBoolean("lobotomize.villager.enabled", lobotomizeVillagerEnabled);
|
||||
+ lobotomizeVillagerCheckInterval = getInt("lobotomize.villager.check-interval", lobotomizeVillagerCheckInterval);
|
||||
+ lobotomizeVillagerCheckCanJump = getBoolean("lobotomize.villager.check-can-jump", lobotomizeVillagerCheckCanJump);
|
||||
+ lobotomizeVillagerCheckOnBed = getBoolean("lobotomize.villager.check-on-bed", lobotomizeVillagerCheckOnBed);
|
||||
+ lobotomizeVillagerCheckActionBlock = getBoolean("lobotomize.villager.check-action-block", lobotomizeVillagerCheckActionBlock);
|
||||
+ lobotomizeVillagerCheckJobSite = getBoolean("lobotomize.villager.check-job-site", lobotomizeVillagerCheckJobSite);
|
||||
+ lobotomizeVillagerCheckBedNearby = getBoolean("lobotomize.villager.check-bed-nearby", lobotomizeVillagerCheckBedNearby);
|
||||
}
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
index aed1d9ccffe471b6c2a1d52d2d3d097f6431318b..0227e8d4f810c6fb90779cb3d257ca04ec927b79 100644
|
||||
index 26857b0e5134f56df47115031727e0ad68216bc6..ee50c838a7fb032e533ab3f861f843b8f8276772 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -200,14 +200,14 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -45,31 +49,34 @@ index aed1d9ccffe471b6c2a1d52d2d3d097f6431318b..0227e8d4f810c6fb90779cb3d257ca04
|
||||
interval *= 2;
|
||||
}
|
||||
- if (this.level.getGameTime() % interval == 0) {
|
||||
- // offset Y for short blocks like dirt_path/farmland TODO: check that it works
|
||||
- this.isLobotomized = !canTravelFrom(this.getBlockPosBelowThatAffectsMyMovement());
|
||||
+ if ((this.getId() + this.tickCount) % interval == 0) { // Kaiiju - Avoid check lags
|
||||
// offset Y for short blocks like dirt_path/farmland
|
||||
- this.isLobotomized = !canTravelFrom(new BlockPos(getX(), getY() + 0.0625D, getZ()));
|
||||
+ // offset Y for short blocks like dirt_path/farmland
|
||||
+ this.isLobotomized = needLobotomy(); // Kaiiju - Override
|
||||
|
||||
if (this.isLobotomized) {
|
||||
this.notLobotomizedCount = 0;
|
||||
@@ -219,9 +219,76 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -219,8 +219,82 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
|
||||
private boolean canTravelFrom(BlockPos pos) {
|
||||
- return canTravelTo(pos.east()) || canTravelTo(pos.west()) || canTravelTo(pos.north()) || canTravelTo(pos.south());
|
||||
+ return canInteractAt(pos.east()) || canInteractAt(pos.west()) || canInteractAt(pos.north()) || canInteractAt(pos.south()); // Kaiiju
|
||||
}
|
||||
|
||||
- }
|
||||
+ // Kaiiju start - Customize canTravelTo checks
|
||||
+ return canInteractAt(pos.east()) || canInteractAt(pos.west()) || canInteractAt(pos.north()) || canInteractAt(pos.south());
|
||||
+ }
|
||||
+
|
||||
+ private boolean needLobotomy() {
|
||||
+ if (this.isSleeping()) return false;
|
||||
+ if (this.level.kaiijuConfig.lobotomizeVillagerCheckOnBed && isOnBed()) return false;
|
||||
+ return !canTravelFrom(new BlockPos(getX(), getY() + 0.5D, getZ()));
|
||||
+ return !canTravelFrom(new BlockPos(this.getBlockX(), (int) (this.getY() + 0.5D), this.getBlockZ()));
|
||||
+ }
|
||||
+
|
||||
+ private boolean canInteractAt(BlockPos pos) {
|
||||
+ net.minecraft.world.level.block.state.BlockState top = null;
|
||||
+ // Check if mob can jump over block
|
||||
+ // STEP 1: CHECK IF MOB CAN MOVE
|
||||
+ // A/ MOVE BY JUMPING
|
||||
+ if (this.level.kaiijuConfig.lobotomizeVillagerCheckCanJump && this.canJump()) {
|
||||
+ top = this.level.getBlockStateIfLoaded(pos.above());
|
||||
+ if (top == null) return false;
|
||||
@@ -78,46 +85,52 @@ index aed1d9ccffe471b6c2a1d52d2d3d097f6431318b..0227e8d4f810c6fb90779cb3d257ca04
|
||||
+ if (above.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND)) return true;
|
||||
+ }
|
||||
+ }
|
||||
+ // Otherwise, check if mob can interact with bottom block
|
||||
+ // B/ MOVE BY WALKING
|
||||
+ net.minecraft.world.level.block.state.BlockState bottom = this.level.getBlockStateIfLoaded(pos);
|
||||
+ if (bottom == null) return false;
|
||||
+ net.minecraft.world.level.block.Block bottomBlock = bottom.getBlock();
|
||||
+ // BED CHECK
|
||||
+ if (isTallBlock(bottomBlock)) return false;
|
||||
+ if (this.level.kaiijuConfig.lobotomizeVillagerCheckActionBlock && isInteractiveBlock(bottomBlock, this.getVillagerData().getProfession())) return true;
|
||||
+ // If he can't interact, check if he can travel
|
||||
+ if (this.level.kaiijuConfig.lobotomizeVillagerCheckBedNearby && isBed(bottomBlock)) return true;
|
||||
+ if (!bottom.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND)) return false;
|
||||
+ if (top == null) top = this.level.getBlockState(pos.above());
|
||||
+ return top.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND);
|
||||
+ if (!top.isPathfindable(level, pos, net.minecraft.world.level.pathfinder.PathComputationType.LAND)) return false;
|
||||
+ // STEP 2: IF ITS NEAR IS JOB SITE: LOBOTOMIZE
|
||||
+ return !(this.level.kaiijuConfig.lobotomizeVillagerCheckJobSite && isAssociatedJobSite(bottomBlock, this.getVillagerData().getProfession()));
|
||||
+ }
|
||||
+
|
||||
+ private boolean canJump() {
|
||||
+ BlockPos pos = new BlockPos(getX(), getY() + 2.5D, getZ());
|
||||
+ BlockPos pos = new BlockPos(this.getBlockX(), (int) (this.getY() + 2.5D), this.getBlockZ());
|
||||
+ net.minecraft.world.level.block.Block above = this.level.getBlockIfLoaded(pos);
|
||||
+ return !above.hasCollision;
|
||||
+ }
|
||||
+
|
||||
+ private boolean isOnBed() {
|
||||
+ BlockPos pos = new BlockPos(getX(), getY() - 0.5D, getZ());
|
||||
+ BlockPos pos = new BlockPos(this.getBlockX(), (int) (this.getY() - 0.5D), this.getBlockZ());
|
||||
+ net.minecraft.world.level.block.Block below = this.level.getBlockIfLoaded(pos);
|
||||
+ return below instanceof net.minecraft.world.level.block.BedBlock;
|
||||
+ return isBed(below);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean isInteractiveBlock(net.minecraft.world.level.block.Block block, VillagerProfession profession) {
|
||||
+ if (block instanceof net.minecraft.world.level.block.BedBlock) return true;
|
||||
+ if (profession == VillagerProfession.NITWIT) return false;
|
||||
+ return (block instanceof net.minecraft.world.level.block.BlastFurnaceBlock && profession != VillagerProfession.ARMORER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.SmokerBlock && profession != VillagerProfession.BUTCHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.CartographyTableBlock && profession != VillagerProfession.CARTOGRAPHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.BrewingStandBlock && profession != VillagerProfession.CLERIC) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.ComposterBlock && profession != VillagerProfession.FARMER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.BarrelBlock && profession != VillagerProfession.FISHERMAN) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.FletchingTableBlock && profession != VillagerProfession.FLETCHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.CauldronBlock && profession != VillagerProfession.LEATHERWORKER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.LecternBlock && profession != VillagerProfession.LIBRARIAN) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.StonecutterBlock && profession != VillagerProfession.MASON) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.LoomBlock && profession != VillagerProfession.SHEPHERD) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.SmithingTableBlock && profession != VillagerProfession.TOOLSMITH) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.GrindstoneBlock && profession != VillagerProfession.WEAPONSMITH);
|
||||
+ private static boolean isBed(net.minecraft.world.level.block.Block block) {
|
||||
+ return block instanceof net.minecraft.world.level.block.BedBlock;
|
||||
+ }
|
||||
+
|
||||
+ private boolean isAssociatedJobSite(net.minecraft.world.level.block.Block block, VillagerProfession profession) {
|
||||
+ if (profession == VillagerProfession.NONE) return false;
|
||||
+ if (this.lastTradedPlayer == null) return true;
|
||||
+ return (block instanceof net.minecraft.world.level.block.BlastFurnaceBlock && profession == VillagerProfession.ARMORER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.SmokerBlock && profession == VillagerProfession.BUTCHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.CartographyTableBlock && profession == VillagerProfession.CARTOGRAPHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.BrewingStandBlock && profession == VillagerProfession.CLERIC) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.ComposterBlock && profession == VillagerProfession.FARMER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.BarrelBlock && profession == VillagerProfession.FISHERMAN) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.FletchingTableBlock && profession == VillagerProfession.FLETCHER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.CauldronBlock && profession == VillagerProfession.LEATHERWORKER) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.LecternBlock && profession == VillagerProfession.LIBRARIAN) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.StonecutterBlock && profession == VillagerProfession.MASON) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.LoomBlock && profession == VillagerProfession.SHEPHERD) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.SmithingTableBlock && profession == VillagerProfession.TOOLSMITH) ||
|
||||
+ (block instanceof net.minecraft.world.level.block.GrindstoneBlock && profession == VillagerProfession.WEAPONSMITH);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean isTallBlock(net.minecraft.world.level.block.Block block) {
|
||||
@@ -126,11 +139,10 @@ index aed1d9ccffe471b6c2a1d52d2d3d097f6431318b..0227e8d4f810c6fb90779cb3d257ca04
|
||||
+ block instanceof net.minecraft.world.level.block.WallBlock;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
|
||||
private boolean canTravelTo(BlockPos pos) {
|
||||
net.minecraft.world.level.block.state.BlockState state = this.level.getBlockStateIfLoaded(pos);
|
||||
if (state == null) {
|
||||
@@ -337,7 +404,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -337,7 +411,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
protected void mobTick(boolean inactive) {
|
||||
//this.level.getProfiler().push("villagerBrain"); // Purpur
|
||||
// Purpur start
|
||||
@@ -139,7 +151,16 @@ index aed1d9ccffe471b6c2a1d52d2d3d097f6431318b..0227e8d4f810c6fb90779cb3d257ca04
|
||||
// treat as inactive if lobotomized
|
||||
inactive = inactive || checkLobotomized();
|
||||
} else {
|
||||
@@ -647,6 +714,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -380,7 +454,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
this.lastTradedPlayer = null;
|
||||
}
|
||||
|
||||
- if (!inactive && !this.isNoAi() && this.random.nextInt(100) == 0) { // Paper
|
||||
+ if ((!inactive || this.isLobotomized) && !this.isNoAi() && this.random.nextInt(100) == 0) { // Paper // Kaiiju
|
||||
Raid raid = ((ServerLevel) this.level).getRaidAt(this.blockPosition());
|
||||
|
||||
if (raid != null && raid.isActive() && !raid.isOver()) {
|
||||
@@ -659,6 +733,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
if (this.assignProfessionWhenSpawned) {
|
||||
nbt.putBoolean("AssignProfessionWhenSpawned", true);
|
||||
}
|
||||
@@ -147,7 +168,7 @@ index aed1d9ccffe471b6c2a1d52d2d3d097f6431318b..0227e8d4f810c6fb90779cb3d257ca04
|
||||
|
||||
}
|
||||
|
||||
@@ -687,6 +755,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -699,6 +774,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
if (nbt.contains("AssignProfessionWhenSpawned")) {
|
||||
this.assignProfessionWhenSpawned = nbt.getBoolean("AssignProfessionWhenSpawned");
|
||||
}
|
||||
|
||||
18
patches/server/0008-Kaiiju-Network-Configuration.patch
Normal file
18
patches/server/0008-Kaiiju-Network-Configuration.patch
Normal file
@@ -0,0 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Thu, 16 Feb 2023 01:38:59 +0200
|
||||
Subject: [PATCH] Kaiiju Network Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
index b86c90cc3601e666998cfa12f44515f605bb53eb..7c6d43d8a360530344ef296f4477750c8a298607 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -198,4 +198,7 @@ public class KaiijuConfig {
|
||||
private static void regionFormatSettings() {
|
||||
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
||||
}
|
||||
+
|
||||
+ private static void networkSettings() {
|
||||
+ }
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||
Date: Thu, 16 Feb 2023 01:49:54 +0200
|
||||
Subject: [PATCH] Purpur Network 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 7c6d43d8a360530344ef296f4477750c8a298607..ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -198,7 +198,10 @@ public class KaiijuConfig {
|
||||
private static void regionFormatSettings() {
|
||||
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
||||
}
|
||||
+
|
||||
+ public static boolean sendNullEntityPackets = true;
|
||||
|
||||
private static void networkSettings() {
|
||||
+ sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 6afee2a744a3498d4a0eee35f77cde444f73d12c..06439712c2bfd0e817d8b9d8c301dc0283eb3ef4 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -207,6 +207,11 @@ public class ServerEntity {
|
||||
flag4 = true;
|
||||
flag5 = true;
|
||||
}
|
||||
+ // Kaiiju start - Don't send null move entity packets
|
||||
+ if (!dev.kaiijumc.kaiiju.KaiijuConfig.sendNullEntityPackets && isNullMovePacket(packet1)) {
|
||||
+ packet1 = null;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
}
|
||||
|
||||
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
||||
@@ -281,6 +286,20 @@ public class ServerEntity {
|
||||
}));
|
||||
}
|
||||
|
||||
+ // Kaiiju start - Don't send null move entity packets
|
||||
+ private boolean isNullMovePacket(Packet<?> packet) {
|
||||
+ if (packet instanceof ClientboundMoveEntityPacket move) {
|
||||
+ if (packet instanceof ClientboundMoveEntityPacket.Pos)
|
||||
+ return move.getXa() == 0 && move.getYa() == 0 && move.getZa() == 0;
|
||||
+ if (packet instanceof ClientboundMoveEntityPacket.PosRot)
|
||||
+ return move.getXa() == 0 && move.getYa() == 0 && move.getZa() == 0 && move.getyRot() == 0 && move.getxRot() == 0;
|
||||
+ if (packet instanceof ClientboundMoveEntityPacket.Rot)
|
||||
+ return move.getyRot() == 0 && move.getxRot() == 0;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
public void removePairing(ServerPlayer player) {
|
||||
this.entity.stopSeenByPlayer(player);
|
||||
player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()}));
|
||||
20
patches/server/0010-Kaiiju-Lithium-Configuration.patch
Normal file
20
patches/server/0010-Kaiiju-Lithium-Configuration.patch
Normal 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: 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 6f16786e6107b9e9b52cdbd052c633e757fe351f..913f2f26b1d022e8a812af7caa5dfca5fa548782 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -204,4 +204,9 @@ public class KaiijuConfig {
|
||||
private static void networkSettings() {
|
||||
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||
}
|
||||
+
|
||||
+ public static boolean lithiumEnable = true;
|
||||
+ private static void lithiumSettings() {
|
||||
+ lithiumEnable = getBoolean("lithium.enable", lithiumEnable);
|
||||
+ }
|
||||
}
|
||||
125
patches/server/0011-Lithium-Math-FastUtil.patch
Normal file
125
patches/server/0011-Lithium-Math-FastUtil.patch
Normal file
@@ -0,0 +1,125 @@
|
||||
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 3a59a816fe35a0f329fbbde871dcb1933015990d..c044fc55f106e521bacf58424d1284069730bbf3 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -206,7 +206,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 eaa620ad86abfb151b43f697973cbc731e2e5e92..e64a6f0d1b03c164d68ca8429d9f87c2dc90870a 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);
|
||||
}
|
||||
|
||||
@@ -454,6 +455,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 5b98d42b5d6bc07265fbb017e51a6281c148436a..e307429919ea4719dec89d7c7b54b888dd12b030 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);
|
||||
}
|
||||
|
||||
149
patches/server/0012-Lithium-Math-SineLut.patch
Normal file
149
patches/server/0012-Lithium-Math-SineLut.patch
Normal file
@@ -0,0 +1,149 @@
|
||||
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 c044fc55f106e521bacf58424d1284069730bbf3..1fe1435b1cfe547ddbfccca01de580b8f0e59888 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -207,8 +207,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'];
|
||||
}
|
||||
|
||||
102
patches/server/0013-Lithium-Entity-FastRetrieval.patch
Normal file
102
patches/server/0013-Lithium-Entity-FastRetrieval.patch
Normal file
@@ -0,0 +1,102 @@
|
||||
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 1fe1435b1cfe547ddbfccca01de580b8f0e59888..fd50b949135178a777abed362a0516591f5b9c98 100644
|
||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||
@@ -208,9 +208,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);
|
||||
Reference in New Issue
Block a user