Compare commits
135 Commits
build-77
...
dev/1.20.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68de640693 | ||
|
|
daf406eff3 | ||
|
|
5c08f71070 | ||
|
|
236822d92f | ||
|
|
2223418370 | ||
|
|
c2b7aec8f7 | ||
|
|
ad96ea2b9b | ||
|
|
4d0e6c8304 | ||
|
|
3c182ae67e | ||
|
|
95b2d636ab | ||
|
|
52e80e540b | ||
|
|
9cb7ff8b84 | ||
|
|
5897fbdfa6 | ||
|
|
042f11d759 | ||
|
|
1271516e58 | ||
|
|
0648cb49c8 | ||
|
|
35a7588d6d | ||
|
|
dc4931389b | ||
|
|
eb6be9f290 | ||
|
|
6d12ac828a | ||
|
|
baf0a46d91 | ||
|
|
32a11498b4 | ||
|
|
8eb4a79492 | ||
|
|
f8abc46b5e | ||
|
|
1594847f93 | ||
|
|
fd71bdebd5 | ||
|
|
a3c8b4a2b7 | ||
|
|
d514f5744a | ||
|
|
dbd96e6e84 | ||
|
|
6669139413 | ||
|
|
4327944b97 | ||
|
|
b869fc44e0 | ||
|
|
423b2078e8 | ||
|
|
a6cd4d115e | ||
|
|
7e70bc76d9 | ||
|
|
fd509ffe21 | ||
|
|
28de4d3178 | ||
|
|
67b061cda6 | ||
|
|
243f57f124 | ||
|
|
c66ed11b44 | ||
|
|
4edf6f9cd3 | ||
|
|
09e0f58125 | ||
|
|
a95080aaff | ||
|
|
794ce3b533 | ||
|
|
40d552627b | ||
|
|
6b0aab7b0b | ||
|
|
3ca4adc05e | ||
|
|
5df1740ff7 | ||
|
|
5c9fc7f289 | ||
|
|
195dfd4e3a | ||
|
|
755fa2e6a4 | ||
|
|
6392fde2e4 | ||
|
|
589b5f62c3 | ||
|
|
1f0e0e1863 | ||
|
|
449d1e5653 | ||
|
|
349ae3bcce | ||
|
|
8c562b0616 | ||
|
|
6657b9cb08 | ||
|
|
3176184ca6 | ||
|
|
bc3e578199 | ||
|
|
8ead6a39e8 | ||
|
|
78ce8c44b0 | ||
|
|
570012207d | ||
|
|
3ced21898b | ||
|
|
47ffdcfec9 | ||
|
|
cb48e11a50 | ||
|
|
47979cce0c | ||
|
|
5ee903fe44 | ||
|
|
66ca590e7d | ||
|
|
7303dafc78 | ||
|
|
7bbd7429a5 | ||
|
|
319347ed32 | ||
|
|
61f2cb81f4 | ||
|
|
9cd3a602bc | ||
|
|
7c29fb1beb | ||
|
|
f91b81c3a6 | ||
|
|
e6ad43eea4 | ||
|
|
fda258d608 | ||
|
|
3c6f042353 | ||
|
|
21321abd32 | ||
|
|
48ac9b311a | ||
|
|
dd425fd8f0 | ||
|
|
af7f63bf75 | ||
|
|
93f3978b49 | ||
|
|
8056d0c632 | ||
|
|
344af397be | ||
|
|
2ac3df7e8b | ||
|
|
d12a002f3c | ||
|
|
d9ad7304e6 | ||
|
|
087825eb26 | ||
|
|
efa1abc1d7 | ||
|
|
ccebb2b390 | ||
|
|
2ed10d07b0 | ||
|
|
160f0452d0 | ||
|
|
57d89067d7 | ||
|
|
1139843c98 | ||
|
|
fe414e027b | ||
|
|
ab7a79c7b7 | ||
|
|
3044e2a70d | ||
|
|
ee365adb62 | ||
|
|
d78112453c | ||
|
|
42d7d8a151 | ||
|
|
f936afbdfd | ||
|
|
e611832cb7 | ||
|
|
62951f0d92 | ||
|
|
73ab029e4c | ||
|
|
47b4ce394c | ||
|
|
6275320901 | ||
|
|
a113654b36 | ||
|
|
671522acdc | ||
|
|
2779390c6b | ||
|
|
4fc704f16a | ||
|
|
423f48684a | ||
|
|
c027a2e37f | ||
|
|
3ec9267550 | ||
|
|
57bd665a5e | ||
|
|
5faba7039e | ||
|
|
3d7011f7d7 | ||
|
|
74d3638155 | ||
|
|
2da29dfbc5 | ||
|
|
d422fc645c | ||
|
|
53851e72d4 | ||
|
|
7c618748c6 | ||
|
|
f63cf7c1fa | ||
|
|
ea9ab3f27c | ||
|
|
ae5526ff76 | ||
|
|
f6f2314be6 | ||
|
|
4e5feda68f | ||
|
|
b6729158b0 | ||
|
|
d4cd2cf5b3 | ||
|
|
c4741b284e | ||
|
|
65ee54da34 | ||
|
|
7ebfac20b8 | ||
|
|
fa210d634d | ||
|
|
91eaf9966d |
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
@@ -1,8 +1,8 @@
|
|||||||
name: Generate Jars
|
name: Generate Jars
|
||||||
on: [ push, pull_request ]
|
on: [ push, pull_request ]
|
||||||
env:
|
env:
|
||||||
version: '1.19.4'
|
version: '1.20.1'
|
||||||
branch: ver/1.19.4
|
branch: ver/1.20.1
|
||||||
jobs:
|
jobs:
|
||||||
paperclip:
|
paperclip:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -14,9 +14,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
distribution: 'GraalVM'
|
distribution: 'graalvm'
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: 'latest'
|
|
||||||
- name: Configure Git User Details
|
- name: Configure Git User Details
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||||
|
|||||||
7
.github/workflows/release.yml
vendored
7
.github/workflows/release.yml
vendored
@@ -1,8 +1,8 @@
|
|||||||
name: Release Jars
|
name: Release Jars
|
||||||
on: [push, workflow_dispatch]
|
on: [push, workflow_dispatch]
|
||||||
env:
|
env:
|
||||||
version: '1.19.4'
|
version: '1.20.1'
|
||||||
branch: ver/1.19.4
|
branch: ver/1.20.1
|
||||||
jobs:
|
jobs:
|
||||||
paperclip:
|
paperclip:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -14,9 +14,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
distribution: 'GraalVM'
|
distribution: 'graalvm'
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: 'latest'
|
|
||||||
- name: Configure Git User Details
|
- name: Configure Git User Details
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||||
|
|||||||
6
.github/workflows/upstream.yml
vendored
6
.github/workflows/upstream.yml
vendored
@@ -10,9 +10,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Git Repository
|
- name: Checkout Git Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v2.5.0
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
- name: Rebuild Patches
|
- name: Rebuild Patches
|
||||||
run: ./gradlew rebuildPatches --stacktrace
|
run: ./gradlew rebuildPatches --stacktrace
|
||||||
- name: Upload Paperclip jar
|
- name: Upload Paperclip jar
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: kaiiju.jar
|
name: kaiiju.jar
|
||||||
path: build/libs/kaiiju-paperclip-*-reobf.jar
|
path: build/libs/kaiiju-paperclip-*-reobf.jar
|
||||||
|
|||||||
72
README.md
72
README.md
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<img src="https://github.com/kugge/Kaiiju/blob/ver/1.19.3/logo.png?" width="32%" height="32%"/>
|
<img src="https://github.com/kugge/Kaiiju/blob/ver/1.19.3/logo.png?" width="32%" height="32%"/>
|
||||||
<h1>Kaiiju</h1>
|
<h1>Kaiiju</h1>
|
||||||
@@ -12,13 +11,72 @@
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
### Additions
|
### Notable
|
||||||
- **Xymb Linear Format**: Saves about 50% of disk space in OW and Nether and 95% in The End.
|
- **Xymb Linear Format**: A Region file format that reduces disk space usage by about 50%.
|
||||||
- **Auto update**: Update upstream everyday.
|
- **Async Pathfinding**: Petal async pathfinding fixed & reworked.
|
||||||
|
- **Technical Minecraft**: Enable Vanilla exploits such as sand duping, RNG manipulation...
|
||||||
|
|
||||||
|
### Other
|
||||||
|
- **Small optimizations**: Increase server efficiency by disabling unnecessary features.
|
||||||
|
- **Commands**: Restore few commands that were previously removed by Folia.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
region-format:
|
||||||
|
linear:
|
||||||
|
flush-frequency: 10
|
||||||
|
flush-max-threads: 1
|
||||||
|
network:
|
||||||
|
send-null-entity-packets: true
|
||||||
|
alternate-keepalive: false
|
||||||
|
kick-player-on-bad-packet: true
|
||||||
|
optimization:
|
||||||
|
disable-vanish-api: false
|
||||||
|
disable-player-stats: false
|
||||||
|
disable-arm-swing-event: false
|
||||||
|
async-path-processing:
|
||||||
|
enable: false
|
||||||
|
max-threads: 0
|
||||||
|
keepalive: 60
|
||||||
|
gameplay:
|
||||||
|
server-mod-name: Kaiiju
|
||||||
|
shared-random-for-players: true
|
||||||
|
unsupported:
|
||||||
|
disable-ensure-tick-thread-checks: false
|
||||||
|
global-event-synchronization: false
|
||||||
|
world-settings:
|
||||||
|
default:
|
||||||
|
region-format:
|
||||||
|
format: ANVIL
|
||||||
|
linear:
|
||||||
|
compression-level: 1
|
||||||
|
crash-on-broken-symlink: true
|
||||||
|
optimization:
|
||||||
|
shulker-box-drop-contents-when-destroyed: true
|
||||||
|
optimize-hoppers: true
|
||||||
|
tick-when-empty: true
|
||||||
|
enable-entity-throttling: false
|
||||||
|
disable-achievements: false
|
||||||
|
disable-creatures-spawn-events: false
|
||||||
|
disable-dolphin-swim-to-treasure: false
|
||||||
|
gameplay:
|
||||||
|
fix-void-trading: true
|
||||||
|
break-redstone-on-top-of-trap-doors-early: true
|
||||||
|
fix-tripwire-state-inconsistency: true
|
||||||
|
safe-teleportation: true
|
||||||
|
sand-duplication: false
|
||||||
|
teleport-async-on-high-velocity: false
|
||||||
|
```
|
||||||
|
Documentation: [Kaiiju Wiki](https://github.com/KaiijuMC/Kaiiju/wiki/Configuration)
|
||||||
|
|
||||||
### Roadmap
|
### Roadmap
|
||||||
- **Static view distance**: Reduce RAM usage with a "cached" view distance.
|
- **Stash deduplication**: Make giant dupe stashes possible and lagless.
|
||||||
- **Native world conversion**: Convert region file format at startup
|
- **Multithreaded Tracker**: Rework Petal multithreaded tracker.
|
||||||
|
|
||||||
|
## Open to contributions
|
||||||
|
- **Native world conversion**: Convert region file format at startup.
|
||||||
|
- **Performance patch**: Any significative performance patch.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
@@ -29,5 +87,3 @@
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
Original patches are licensed under GPL-3.0.
|
Original patches are licensed under GPL-3.0.
|
||||||
|
|
||||||
Made with <span style="color: #e25555;">♥</span> on Earth.
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.papermc.paperweight.util.constants.*
|
|||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
id("io.papermc.paperweight.patcher") version "1.5.4"
|
id("io.papermc.paperweight.patcher") version "1.5.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@@ -85,7 +85,7 @@ tasks.register("foliaRefLatest") {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val foliaLatestCommitJson = layout.cache.resolve("foliaLatestCommit.json");
|
val foliaLatestCommitJson = layout.cache.resolve("foliaLatestCommit.json");
|
||||||
download.get().download("https://api.github.com/repos/PaperMC/Folia/commits/master", foliaLatestCommitJson);
|
download.get().download("https://api.github.com/repos/PaperMC/Folia/commits/dev/1.20.2", foliaLatestCommitJson);
|
||||||
val foliaLatestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(foliaLatestCommitJson)["sha"].asString;
|
val foliaLatestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(foliaLatestCommitJson)["sha"].asString;
|
||||||
|
|
||||||
copy {
|
copy {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
group = dev.kaiijumc.kaiiju
|
group = dev.kaiijumc.kaiiju
|
||||||
version = 1.19.4-R0.1-SNAPSHOT
|
version = 1.20.2-R0.1-SNAPSHOT
|
||||||
mcVersion = 1.19.4
|
mcVersion = 1.20.2
|
||||||
|
|
||||||
foliaRef = 25e0cbdae46912d227a31703869594538b731931
|
foliaRef = 84aecdc64afc48e73fffe01f6055c453567f2027
|
||||||
|
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Kaiiju Configuration
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
index c230a10aff36f6b484d7e3963cbf8073f8676fb1..6b17fc3c788b745aa458eee82cace12e4728b6b5 100644
|
index b6a8217b97842cd07af24fadb21e0e44226e5bb9..ce7dcbc0709839457df357484620f21c3d7c19c5 100644
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
@@ -1971,6 +1971,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
@@ -2121,6 +2121,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
Date: Fri, 31 Mar 2023 01:52:44 +0300
|
Date: Fri, 31 Mar 2023 01:52:44 +0300
|
||||||
Subject: [PATCH] Purpur Network AlternateKeepalive
|
Subject: [PATCH] Alternate Keepalive
|
||||||
|
|
||||||
|
Don't kick players because 1 keepalive is lost.
|
||||||
|
This patch is from Purpur.
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7..b42a3466f145a92608c8746fd4beb529b4a60b01 100644
|
index 47e23a196ae5e44600a64184b69141c00235baca..95b53b50606ea0ad47f407bebbb9e2bd445c0e66 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
@@ -200,8 +200,10 @@ public class KaiijuConfig {
|
@@ -205,8 +205,10 @@ public class KaiijuConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean sendNullEntityPackets = true;
|
public static boolean sendNullEntityPackets = true;
|
||||||
@@ -20,10 +22,10 @@ index ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7..b42a3466f145a92608c8746fd4beb529
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index 4963e87adf11c9df90f0dd4b60d360a137c07bc9..5f73e794a248a4d11b58b169831622ca1f61aac6 100644
|
index 678bba9d636a0eb34270a2d26b5b3d0d6d900115..564b2e668d50f05863080288d20bd54077588db9 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -261,6 +261,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -265,6 +265,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||||
private long keepAliveTime = Util.getMillis();
|
private long keepAliveTime = Util.getMillis();
|
||||||
private boolean keepAlivePending;
|
private boolean keepAlivePending;
|
||||||
private long keepAliveChallenge;
|
private long keepAliveChallenge;
|
||||||
@@ -31,7 +33,7 @@ index 4963e87adf11c9df90f0dd4b60d360a137c07bc9..5f73e794a248a4d11b58b169831622ca
|
|||||||
// CraftBukkit start - multithreaded fields
|
// CraftBukkit start - multithreaded fields
|
||||||
private final AtomicInteger chatSpamTickCount = new AtomicInteger();
|
private final AtomicInteger chatSpamTickCount = new AtomicInteger();
|
||||||
private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
|
private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
|
||||||
@@ -352,6 +353,20 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -357,6 +358,20 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||||
long currentTime = Util.getMillis();
|
long currentTime = Util.getMillis();
|
||||||
long elapsedTime = currentTime - this.keepAliveTime;
|
long elapsedTime = currentTime - this.keepAliveTime;
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ index 4963e87adf11c9df90f0dd4b60d360a137c07bc9..5f73e794a248a4d11b58b169831622ca
|
|||||||
if (this.keepAlivePending) {
|
if (this.keepAlivePending) {
|
||||||
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
|
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
|
||||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
|
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
|
||||||
@@ -3534,6 +3549,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -3610,6 +3625,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
|
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
|
||||||
@@ -66,6 +68,6 @@ index 4963e87adf11c9df90f0dd4b60d360a137c07bc9..5f73e794a248a4d11b58b169831622ca
|
|||||||
+ }
|
+ }
|
||||||
+ } else
|
+ } else
|
||||||
+ // Kaiiju end
|
+ // Kaiiju end
|
||||||
//PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread
|
//PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread
|
||||||
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
|
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
|
||||||
int i = (int) (Util.getMillis() - this.keepAliveTime);
|
int i = (int) (Util.getMillis() - this.keepAliveTime);
|
||||||
18
patches/removed/0016-Fix-off-thread-raid-winners.patch
Normal file
18
patches/removed/0016-Fix-off-thread-raid-winners.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: Tue, 9 May 2023 15:11:56 +0300
|
||||||
|
Subject: [PATCH] Fix off thread raid winners
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||||
|
index 359f1690497eac00899eb26c17308e0a6fe943ad..3cc320e854cbb9e70b6c63f1f950091c5195edae 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||||
|
@@ -404,6 +404,7 @@ public class Raid {
|
||||||
|
UUID uuid = (UUID) iterator.next();
|
||||||
|
Entity entity = this.level.getEntity(uuid);
|
||||||
|
|
||||||
|
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity)) continue; // Kaiiju - Prevent give effect to player off thread
|
||||||
|
if (entity instanceof LivingEntity && !entity.isSpectator()) {
|
||||||
|
LivingEntity entityliving = (LivingEntity) entity;
|
||||||
|
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Wed, 10 May 2023 16:30:38 +0300
|
||||||
|
Subject: [PATCH] Strip raytracing for EntityLiving#hasLineOfSight
|
||||||
|
|
||||||
|
This has been benchmarked on a huge gold farm.
|
||||||
|
Resulting in significative performance improvements.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
index f636bdf1075fa784ce7ee25478d4d94bacb05677..2da522f89a7c44208ca1ba9139efe723a519fabc 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -3661,7 +3661,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
|
||||||
|
|
||||||
|
// Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists
|
||||||
|
- return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS;
|
||||||
|
+ return !(vec3d1.distanceToSqr(vec3d) > 128D * 128D) && this.level().rayTraceDirect(vec3d, vec3d1, net.minecraft.world.phys.shapes.CollisionContext.of(this)) == net.minecraft.world.phys.BlockHitResult.Type.MISS; // Paper - use distanceToSqr // Kaiiju - Pufferfish - Strip raytracing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||||
|
index 0e8746759752b692668886370181aa5db1fd0bb0..5e2f5e9c21009a71f671955df7a4135ce5cf5b08 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||||
|
@@ -68,6 +68,17 @@ public interface BlockGetter extends LevelHeightAccessor {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Pufferfish - broken down variant of below rayTraceBlock, used by World#rayTraceDirect
|
||||||
|
+ @Nullable
|
||||||
|
+ default net.minecraft.world.phys.BlockHitResult.Type rayTraceBlockDirect(Vec3 vec3d, Vec3 vec3d1, BlockPos blockposition, BlockState iblockdata, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) {
|
||||||
|
+ if (iblockdata.isAir()) return null;
|
||||||
|
+ VoxelShape voxelshape = ClipContext.Block.COLLIDER.get(iblockdata, this, blockposition, voxelshapecoll);
|
||||||
|
+ net.minecraft.world.phys.BlockHitResult movingobjectpositionblock = this.clipWithInteractionOverride(vec3d, vec3d1, blockposition, voxelshape, iblockdata);
|
||||||
|
+
|
||||||
|
+ return movingobjectpositionblock == null ? null : movingobjectpositionblock.getType();
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
|
||||||
|
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
|
||||||
|
// Paper start - Prevent raytrace from loading chunks
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
index fb71843793e699b2ccfaa3b7e4c2bb7d4826a706..42727a50ae11cd4d4aa65eb57638bfb164f1e4ac 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
|
@@ -432,6 +432,91 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Pufferfish - broken down method of raytracing for EntityLiving#hasLineOfSight, replaces IBlockAccess#rayTrace(RayTrace)
|
||||||
|
+ public net.minecraft.world.phys.BlockHitResult.Type rayTraceDirect(net.minecraft.world.phys.Vec3 vec3d, net.minecraft.world.phys.Vec3 vec3d1, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) {
|
||||||
|
+ // most of this code comes from IBlockAccess#a(RayTrace, BiFunction, Function), but removes the needless functions
|
||||||
|
+ if (vec3d.equals(vec3d1)) {
|
||||||
|
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ double endX = Mth.lerp(-1.0E-7D, vec3d1.x, vec3d.x);
|
||||||
|
+ double endY = Mth.lerp(-1.0E-7D, vec3d1.y, vec3d.y);
|
||||||
|
+ double endZ = Mth.lerp(-1.0E-7D, vec3d1.z, vec3d.z);
|
||||||
|
+
|
||||||
|
+ double startX = Mth.lerp(-1.0E-7D, vec3d.x, vec3d1.x);
|
||||||
|
+ double startY = Mth.lerp(-1.0E-7D, vec3d.y, vec3d1.y);
|
||||||
|
+ double startZ = Mth.lerp(-1.0E-7D, vec3d.z, vec3d1.z);
|
||||||
|
+
|
||||||
|
+ int currentX = Mth.floor(startX);
|
||||||
|
+ int currentY = Mth.floor(startY);
|
||||||
|
+ int currentZ = Mth.floor(startZ);
|
||||||
|
+
|
||||||
|
+ BlockPos.MutableBlockPos currentBlock = new BlockPos.MutableBlockPos(currentX, currentY, currentZ);
|
||||||
|
+
|
||||||
|
+ LevelChunk chunk = this.getChunkIfLoaded(currentBlock);
|
||||||
|
+ if (chunk == null) {
|
||||||
|
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ net.minecraft.world.phys.BlockHitResult.Type initialCheck = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll);
|
||||||
|
+
|
||||||
|
+ if (initialCheck != null) {
|
||||||
|
+ return initialCheck;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ double diffX = endX - startX;
|
||||||
|
+ double diffY = endY - startY;
|
||||||
|
+ double diffZ = endZ - startZ;
|
||||||
|
+
|
||||||
|
+ int xDirection = Mth.sign(diffX);
|
||||||
|
+ int yDirection = Mth.sign(diffY);
|
||||||
|
+ int zDirection = Mth.sign(diffZ);
|
||||||
|
+
|
||||||
|
+ double normalizedX = xDirection == 0 ? Double.MAX_VALUE : (double) xDirection / diffX;
|
||||||
|
+ double normalizedY = yDirection == 0 ? Double.MAX_VALUE : (double) yDirection / diffY;
|
||||||
|
+ double normalizedZ = zDirection == 0 ? Double.MAX_VALUE : (double) zDirection / diffZ;
|
||||||
|
+
|
||||||
|
+ double normalizedXDirection = normalizedX * (xDirection > 0 ? 1.0D - Mth.frac(startX) : Mth.frac(startX));
|
||||||
|
+ double normalizedYDirection = normalizedY * (yDirection > 0 ? 1.0D - Mth.frac(startY) : Mth.frac(startY));
|
||||||
|
+ double normalizedZDirection = normalizedZ * (zDirection > 0 ? 1.0D - Mth.frac(startZ) : Mth.frac(startZ));
|
||||||
|
+
|
||||||
|
+ net.minecraft.world.phys.BlockHitResult.Type result;
|
||||||
|
+
|
||||||
|
+ do {
|
||||||
|
+ if (normalizedXDirection > 1.0D && normalizedYDirection > 1.0D && normalizedZDirection > 1.0D) {
|
||||||
|
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (normalizedXDirection < normalizedYDirection) {
|
||||||
|
+ if (normalizedXDirection < normalizedZDirection) {
|
||||||
|
+ currentX += xDirection;
|
||||||
|
+ normalizedXDirection += normalizedX;
|
||||||
|
+ } else {
|
||||||
|
+ currentZ += zDirection;
|
||||||
|
+ normalizedZDirection += normalizedZ;
|
||||||
|
+ }
|
||||||
|
+ } else if (normalizedYDirection < normalizedZDirection) {
|
||||||
|
+ currentY += yDirection;
|
||||||
|
+ normalizedYDirection += normalizedY;
|
||||||
|
+ } else {
|
||||||
|
+ currentZ += zDirection;
|
||||||
|
+ normalizedZDirection += normalizedZ;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ currentBlock.set(currentX, currentY, currentZ);
|
||||||
|
+ if (chunk.getPos().x != currentBlock.getX() >> 4 || chunk.getPos().z != currentBlock.getZ() >> 4) {
|
||||||
|
+ chunk = this.getChunkIfLoaded(currentBlock);
|
||||||
|
+ if (chunk == null) {
|
||||||
|
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ result = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll);
|
||||||
|
+ } while (result == null);
|
||||||
|
+
|
||||||
|
+ return result;
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
public boolean isInWorldBounds(BlockPos pos) {
|
||||||
|
return pos.isInsideBuildHeightAndWorldBoundsHorizontal(this); // Paper - use better/optimized check
|
||||||
|
}
|
||||||
20
patches/removed/0018-Fix-off-thread-spider-addEffect.patch
Normal file
20
patches/removed/0018-Fix-off-thread-spider-addEffect.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: Wed, 10 May 2023 17:58:37 +0300
|
||||||
|
Subject: [PATCH] Fix off thread spider addEffect
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||||
|
index 05432184077752b1d0cb764a5e39ed875748b2d6..74a68ae68e3c774a63d0a5478dfcda6e7894a514 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||||
|
@@ -180,7 +180,9 @@ public class Spider extends Monster {
|
||||||
|
MobEffect mobeffectlist = entityspider_groupdataspider.effect;
|
||||||
|
|
||||||
|
if (mobeffectlist != null) {
|
||||||
|
+ this.getBukkitEntity().taskScheduler.schedule(task -> { // Kaiiju - Fix off thread spider add effect
|
||||||
|
this.addEffect(new MobEffectInstance(mobeffectlist, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit
|
||||||
|
+ }, null, 1); // Kaiiju - Fix off thread spider add effect
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Sat, 17 Jun 2023 19:52:29 +0300
|
||||||
|
Subject: [PATCH] Swap distanceToSqr and target test
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java
|
||||||
|
index b1a6a66ed02706c1adc36dcedfa415f5a24a25a0..97a5eca200fd606d6102e40f9b8c32c2e7652cf9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java
|
||||||
|
@@ -99,9 +99,9 @@ public interface EntityGetter {
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
for(Player player2 : this.getLocalPlayers()) { // Folia - region threading
|
||||||
|
- if (targetPredicate == null || targetPredicate.test(player2)) {
|
||||||
|
+ if (true || targetPredicate == null || targetPredicate.test(player2)) { // Kaiiju - Move this down
|
||||||
|
double e = player2.distanceToSqr(x, y, z);
|
||||||
|
- if ((maxDistance < 0.0D || e < maxDistance * maxDistance) && (d == -1.0D || e < d)) {
|
||||||
|
+ if ((maxDistance < 0.0D || e < maxDistance * maxDistance) && (d == -1.0D || e < d) && (targetPredicate == null || targetPredicate.test(player2))) { // Kaiiju
|
||||||
|
d = e;
|
||||||
|
player = player2;
|
||||||
|
}
|
||||||
|
@@ -147,9 +147,10 @@ public interface EntityGetter {
|
||||||
|
// Paper start
|
||||||
|
default boolean hasNearbyAlivePlayerThatAffectsSpawning(double x, double y, double z, double range) {
|
||||||
|
for (Player player : this.getLocalPlayers()) { // Folia - region threading
|
||||||
|
- if (EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) { // combines NO_SPECTATORS and LIVING_ENTITY_STILL_ALIVE with an "affects spawning" check
|
||||||
|
+ if (true || EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) { // combines NO_SPECTATORS and LIVING_ENTITY_STILL_ALIVE with an "affects spawning" check // Kaiiju - Move this down
|
||||||
|
double distanceSqr = player.distanceToSqr(x, y, z);
|
||||||
|
if (range < 0.0D || distanceSqr < range * range) {
|
||||||
|
+ if (EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) // Kaiiju
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -199,9 +200,9 @@ public interface EntityGetter {
|
||||||
|
T livingEntity = null;
|
||||||
|
|
||||||
|
for(T livingEntity2 : entityList) {
|
||||||
|
- if (targetPredicate.test(entity, livingEntity2)) {
|
||||||
|
+ if (true || targetPredicate.test(entity, livingEntity2)) { // Kaiiju - Move this down
|
||||||
|
double e = livingEntity2.distanceToSqr(x, y, z);
|
||||||
|
- if (d == -1.0D || e < d) {
|
||||||
|
+ if ((d == -1.0D || e < d) && targetPredicate.test(entity, livingEntity2)) { // Kaiiju
|
||||||
|
d = e;
|
||||||
|
livingEntity = livingEntity2;
|
||||||
|
}
|
||||||
18
patches/removed/0032-Fix-visual-respawn-issue.patch
Normal file
18
patches/removed/0032-Fix-visual-respawn-issue.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: Wed, 21 Jun 2023 04:15:44 +0300
|
||||||
|
Subject: [PATCH] Fix visual respawn issue
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
index 10c7f5c6fc0e5cb8aafbe125dd68635a37b7b1b9..6f589e7e4bbed0b2fa87403c86f18d36672cf1d0 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -633,6 +633,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
++this.deathTime;
|
||||||
|
if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved() && !this.broadcastedDeath) { // Folia - region threading
|
||||||
|
this.level().broadcastEntityEvent(this, (byte) 60);
|
||||||
|
+ this.broadcastedDeath = true; // Kaiiju - Fix respawn issue / Visual bug
|
||||||
|
if (!(this instanceof ServerPlayer)) this.remove(Entity.RemovalReason.KILLED); // Folia - region threading - don't remove, we want the tick scheduler to be running
|
||||||
|
if ((this instanceof ServerPlayer)) this.unRide(); // Folia - region threading - unmount player when dead
|
||||||
|
}
|
||||||
46
patches/removed/0038-Don-t-kick-player-on-bad-packet.patch
Normal file
46
patches/removed/0038-Don-t-kick-player-on-bad-packet.patch
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 2 Jul 2023 19:13:14 +0300
|
||||||
|
Subject: [PATCH] Don't kick player on bad packet
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index 12738605442b9cdd086b2b29ff372d12552993b8..c0432bb14df86fe070c90deb33aa8c535cfe46f3 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -206,10 +206,12 @@ public class KaiijuConfig {
|
||||||
|
|
||||||
|
public static boolean sendNullEntityPackets = true;
|
||||||
|
public static boolean alternateKeepAlive = false;
|
||||||
|
+ public static boolean kickPlayerOnBadPacket = true;
|
||||||
|
|
||||||
|
private static void networkSettings() {
|
||||||
|
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||||
|
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
||||||
|
+ kickPlayerOnBadPacket = getBoolean("network.kick-player-on-bad-packet", kickPlayerOnBadPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean disableVanishApi = false;
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||||
|
index f6ccb6eab566b44c3460376d46df1f2cf3d7b19d..13e5aeb0c04d27408ffbc6b11582426a7f2eb0f0 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||||
|
@@ -271,12 +271,18 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||||
|
ConnectionProtocol enumprotocol = this.getCurrentProtocol();
|
||||||
|
Packet<?> packet = enumprotocol == ConnectionProtocol.LOGIN ? new ClientboundLoginDisconnectPacket(ichatmutablecomponent) : new ClientboundDisconnectPacket(ichatmutablecomponent);
|
||||||
|
|
||||||
|
+ // Kaiiju start - Don't kick player on bad packet
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.kickPlayerOnBadPacket
|
||||||
|
+ || throwable instanceof io.netty.channel.unix.Errors.NativeIoException) {
|
||||||
|
+ // Kaiiju end
|
||||||
|
this.send((Packet) packet, PacketSendListener.thenRun(() -> {
|
||||||
|
this.disconnect(ichatmutablecomponent);
|
||||||
|
}));
|
||||||
|
this.setReadOnly();
|
||||||
|
+ } // Kaiiju - Don't kick player on bad packet
|
||||||
|
} else {
|
||||||
|
Connection.LOGGER.debug("Double fault", throwable);
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.kickPlayerOnBadPacket) // Kaiiju - Don't kick player on bad packet
|
||||||
|
this.disconnect(ichatmutablecomponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
patches/removed/0039-Fix-teleportAsync-rotation-API.patch
Normal file
19
patches/removed/0039-Fix-teleportAsync-rotation-API.patch
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: kugge <sofiane.djerbi38@gmail.com>
|
||||||
|
Date: Thu, 22 Jun 2023 20:32:58 +0200
|
||||||
|
Subject: [PATCH] Fix teleportAsync rotation API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||||
|
index 76bcfda336e9cfa039d80ea3ccbebbc3d2b13f7f..24617b3994c0f148f1c17928e18aa1e1a784e6f5 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||||
|
@@ -1329,7 +1329,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||||
|
boolean success = nmsEntity.teleportAsync(
|
||||||
|
((CraftWorld)locationClone.getWorld()).getHandle(),
|
||||||
|
new net.minecraft.world.phys.Vec3(locationClone.getX(), locationClone.getY(), locationClone.getZ()),
|
||||||
|
- null, null, net.minecraft.world.phys.Vec3.ZERO,
|
||||||
|
+ locationClone.getYaw(), locationClone.getPitch(), net.minecraft.world.phys.Vec3.ZERO, // Kaiiju - fix teleportAsync() rotation
|
||||||
|
cause == null ? TeleportCause.UNKNOWN : cause,
|
||||||
|
Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_UNMOUNT, // preserve behavior with old API: dismount the entity so it can teleport
|
||||||
|
(Entity entityTp) -> {
|
||||||
@@ -0,0 +1,458 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Sauve <paul@technove.co>
|
||||||
|
Date: Tue, 1 Aug 2023 03:38:09 +0200
|
||||||
|
Subject: [PATCH] Improve container checking with a bitset
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/structs/ItemListWithBitset.java b/src/main/java/dev/kaiijumc/kaiiju/structs/ItemListWithBitset.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..ee32b7c4a1ae1e23149694ecba5ab7bd347d6ca6
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/structs/ItemListWithBitset.java
|
||||||
|
@@ -0,0 +1,114 @@
|
||||||
|
+package dev.kaiijumc.kaiiju.structs;
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+import net.minecraft.core.NonNullList;
|
||||||
|
+import net.minecraft.world.item.ItemStack;
|
||||||
|
+import org.apache.commons.lang.Validate;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+import java.util.AbstractList;
|
||||||
|
+import java.util.Arrays;
|
||||||
|
+import java.util.List;
|
||||||
|
+
|
||||||
|
+public class ItemListWithBitset extends AbstractList<ItemStack> {
|
||||||
|
+ public static ItemListWithBitset fromList(List<ItemStack> list) {
|
||||||
|
+ if (list instanceof ItemListWithBitset ours) {
|
||||||
|
+ return ours;
|
||||||
|
+ }
|
||||||
|
+ return new ItemListWithBitset(list);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static ItemStack[] createArray(int size) {
|
||||||
|
+ ItemStack[] array = new ItemStack[size];
|
||||||
|
+ Arrays.fill(array, ItemStack.EMPTY);
|
||||||
|
+ return array;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private final ItemStack[] items;
|
||||||
|
+
|
||||||
|
+ private long bitSet = 0;
|
||||||
|
+ private final long allBits;
|
||||||
|
+
|
||||||
|
+ private static class OurNonNullList extends NonNullList<ItemStack> {
|
||||||
|
+ protected OurNonNullList(List<ItemStack> delegate) {
|
||||||
|
+ super(delegate, ItemStack.EMPTY);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public final NonNullList<ItemStack> nonNullList = new OurNonNullList(this);
|
||||||
|
+
|
||||||
|
+ private ItemListWithBitset(List<ItemStack> list) {
|
||||||
|
+ this(list.size());
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < list.size(); i++) {
|
||||||
|
+ this.set(i, list.get(i));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ItemListWithBitset(int size) {
|
||||||
|
+ Validate.isTrue(size < Long.BYTES * 8, "size is too large");
|
||||||
|
+
|
||||||
|
+ this.items = createArray(size);
|
||||||
|
+ this.allBits = ((1L << size) - 1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean isCompletelyEmpty() {
|
||||||
|
+ return this.bitSet == 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean hasFullStacks() {
|
||||||
|
+ return (this.bitSet & this.allBits) == allBits;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public ItemStack set(int index, @NotNull ItemStack itemStack) {
|
||||||
|
+ ItemStack existing = this.items[index];
|
||||||
|
+
|
||||||
|
+ this.items[index] = itemStack;
|
||||||
|
+
|
||||||
|
+ if (itemStack == ItemStack.EMPTY) {
|
||||||
|
+ this.bitSet &= ~(1L << index);
|
||||||
|
+ } else {
|
||||||
|
+ this.bitSet |= 1L << index;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return existing;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public ItemStack get(int var0) {
|
||||||
|
+ return this.items[var0];
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int size() {
|
||||||
|
+ return this.items.length;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void clear() {
|
||||||
|
+ Arrays.fill(this.items, ItemStack.EMPTY);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // these are unsupported for block inventories which have a static size
|
||||||
|
+ @Override
|
||||||
|
+ public void add(int var0, ItemStack var1) {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public ItemStack remove(int var0) {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String toString() {
|
||||||
|
+ return "ItemListWithBitset{" +
|
||||||
|
+ "items=" + Arrays.toString(items) +
|
||||||
|
+ ", bitSet=" + Long.toString(bitSet, 2) +
|
||||||
|
+ ", allBits=" + Long.toString(allBits, 2) +
|
||||||
|
+ ", size=" + this.items.length +
|
||||||
|
+ '}';
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/CompoundContainer.java b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||||
|
index 241fec02e6869c638d3a160819b32173a081467b..62848ca68f532fa14241320df76d180c13072c34 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||||
|
@@ -64,6 +64,23 @@ public class CompoundContainer implements Container {
|
||||||
|
this.container2 = second;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - airplane - improve container checking with a bitset
|
||||||
|
+ @Override
|
||||||
|
+ public boolean hasEmptySlot(net.minecraft.core.Direction enumdirection) {
|
||||||
|
+ return this.container1.hasEmptySlot(null) || this.container2.hasEmptySlot(null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyFull(net.minecraft.core.Direction enumdirection) {
|
||||||
|
+ return this.container1.isCompletelyFull(null) && this.container2.isCompletelyFull(null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyEmpty(net.minecraft.core.Direction enumdirection) {
|
||||||
|
+ return this.container1.isCompletelyEmpty(null) && this.container2.isCompletelyEmpty(null);
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public int getContainerSize() {
|
||||||
|
return this.container1.getContainerSize() + this.container2.getContainerSize();
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java
|
||||||
|
index 04b1531572e8fff1e46fe1c94e7fc863841e0f66..ac1e21a4fc210424ea57c247d03914c54129de9c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/Container.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/Container.java
|
||||||
|
@@ -13,6 +13,63 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
public interface Container extends Clearable {
|
||||||
|
+ // Kaiiju start - airplane - allow the inventory to override and optimize these frequent calls
|
||||||
|
+ default boolean hasEmptySlot(@org.jetbrains.annotations.Nullable net.minecraft.core.Direction enumdirection) { // there is a slot with 0 items in it
|
||||||
|
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||||
|
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||||
|
+ if (this.getItem(i).isEmpty()) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ int size = this.getContainerSize();
|
||||||
|
+ for (int i = 0; i < size; i++) {
|
||||||
|
+ if (this.getItem(i).isEmpty()) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ default boolean isCompletelyFull(@org.jetbrains.annotations.Nullable net.minecraft.core.Direction enumdirection) { // every stack is maxed
|
||||||
|
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||||
|
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||||
|
+ ItemStack itemStack = this.getItem(i);
|
||||||
|
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ int size = this.getContainerSize();
|
||||||
|
+ for (int i = 0; i < size; i++) {
|
||||||
|
+ ItemStack itemStack = this.getItem(i);
|
||||||
|
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ default boolean isCompletelyEmpty(@org.jetbrains.annotations.Nullable net.minecraft.core.Direction enumdirection) {
|
||||||
|
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||||
|
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||||
|
+ if (!this.getItem(i).isEmpty()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ int size = this.getContainerSize();
|
||||||
|
+ for (int i = 0; i < size; i++) {
|
||||||
|
+ if (!this.getItem(i).isEmpty()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
|
||||||
|
int LARGE_MAX_STACK_SIZE = 64;
|
||||||
|
int DEFAULT_DISTANCE_LIMIT = 8;
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
index 272095d7a09ab41227d741172735f66fd2798ce1..1f2e2d7726abd63bb46697697c91696387c819a2 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
@@ -28,6 +28,7 @@ import org.bukkit.inventory.InventoryHolder;
|
||||||
|
public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity {
|
||||||
|
|
||||||
|
private NonNullList<ItemStack> itemStacks;
|
||||||
|
+ private dev.kaiijumc.kaiiju.structs.ItemListWithBitset itemStacksOptimized; // Kaiiju - airplane - implement ItemListWithBitset
|
||||||
|
@Nullable
|
||||||
|
public ResourceLocation lootTable;
|
||||||
|
public long lootTableSeed;
|
||||||
|
@@ -89,12 +90,18 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||||
|
|
||||||
|
protected AbstractMinecartContainer(EntityType<?> type, Level world) {
|
||||||
|
super(type, world);
|
||||||
|
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.itemStacksOptimized = new dev.kaiijumc.kaiiju.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractMinecartContainer(EntityType<?> type, double x, double y, double z, Level world) {
|
||||||
|
super(type, world, x, y, z);
|
||||||
|
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.itemStacksOptimized = new dev.kaiijumc.kaiiju.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -156,6 +163,10 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||||
|
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||||
|
super.readAdditionalSaveData(nbt);
|
||||||
|
this.lootableData.loadNbt(nbt); // Paper
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.itemStacksOptimized = new dev.kaiijumc.kaiiju.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||||
|
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
this.readChestVehicleSaveData(nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
|
index a71414397bd45ee7bcacfeef0041d80dfa25f114..67f69540e6c217070f8d2af8908d4eb6f2b5c1c1 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
|
@@ -31,6 +31,7 @@ import org.bukkit.entity.HumanEntity;
|
||||||
|
public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity {
|
||||||
|
|
||||||
|
private static final int EVENT_SET_OPEN_COUNT = 1;
|
||||||
|
+ private dev.kaiijumc.kaiiju.structs.ItemListWithBitset optimizedItems; // Kaiiju - airplane - implement ItemListWithBitset
|
||||||
|
private NonNullList<ItemStack> items;
|
||||||
|
public final ContainerOpenersCounter openersCounter;
|
||||||
|
private final ChestLidController chestLidController;
|
||||||
|
@@ -65,9 +66,14 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
+ private final boolean isNative = getClass().equals(ChestBlockEntity.class); // Kaiiju - airplane
|
||||||
|
+
|
||||||
|
protected ChestBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||||
|
super(type, pos, state);
|
||||||
|
- this.items = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.optimizedItems = new dev.kaiijumc.kaiiju.structs.ItemListWithBitset(27);
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
this.openersCounter = new ContainerOpenersCounter() {
|
||||||
|
@Override
|
||||||
|
protected void onOpen(Level world, BlockPos pos, BlockState state) {
|
||||||
|
@@ -98,6 +104,23 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
this.chestLidController = new ChestLidController();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - airplane - improve container checking with a bitset
|
||||||
|
+ @Override
|
||||||
|
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||||
|
+ return isNative ? !this.optimizedItems.hasFullStacks() : super.hasEmptySlot(enumdirection);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||||
|
+ return isNative ? this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection) : super.isCompletelyFull(enumdirection);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||||
|
+ return isNative && this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
public ChestBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
this(BlockEntityType.CHEST, pos, state);
|
||||||
|
}
|
||||||
|
@@ -115,7 +138,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
@Override
|
||||||
|
public void load(CompoundTag nbt) {
|
||||||
|
super.load(nbt);
|
||||||
|
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.optimizedItems = new dev.kaiijumc.kaiiju.structs.ItemListWithBitset(this.getContainerSize());
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
if (!this.tryLoadLootTable(nbt)) {
|
||||||
|
ContainerHelper.loadAllItems(nbt, this.items);
|
||||||
|
}
|
||||||
|
@@ -187,7 +213,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setItems(NonNullList<ItemStack> list) {
|
||||||
|
- this.items = list;
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.optimizedItems = dev.kaiijumc.kaiiju.structs.ItemListWithBitset.fromList(list);
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
index 8781a7cebf66007158286f265e2adbaf40c1d2ff..6d55a6687060bdb6b2286e294d09ef0093b1625e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
@@ -48,6 +48,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
public static final int MOVE_ITEM_SPEED = 8;
|
||||||
|
public static final int HOPPER_CONTAINER_SIZE = 5;
|
||||||
|
private NonNullList<ItemStack> items;
|
||||||
|
+ private dev.kaiijumc.kaiiju.structs.ItemListWithBitset optimizedItems; // Kaiiju - airplane - implement ItemListWithBitset
|
||||||
|
private int cooldownTime;
|
||||||
|
private long tickedGameTime;
|
||||||
|
|
||||||
|
@@ -83,14 +84,37 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
|
||||||
|
public HopperBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
super(BlockEntityType.HOPPER, pos, state);
|
||||||
|
- this.items = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.optimizedItems = new dev.kaiijumc.kaiiju.structs.ItemListWithBitset(5);
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
this.cooldownTime = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - airplane - improve container checking with a bitset
|
||||||
|
+ @Override
|
||||||
|
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||||
|
+ return !this.optimizedItems.hasFullStacks();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||||
|
+ return this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||||
|
+ return this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public void load(CompoundTag nbt) {
|
||||||
|
super.load(nbt);
|
||||||
|
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.optimizedItems = new dev.kaiijumc.kaiiju.structs.ItemListWithBitset(this.getContainerSize());
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
if (!this.tryLoadLootTable(nbt)) {
|
||||||
|
ContainerHelper.loadAllItems(nbt, this.items);
|
||||||
|
}
|
||||||
|
@@ -162,7 +186,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
flag = HopperBlockEntity.ejectItems(world, pos, state, (Container) blockEntity, blockEntity); // CraftBukkit
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!blockEntity.inventoryFull()) {
|
||||||
|
+ if (!blockEntity.optimizedItems.hasFullStacks() || !blockEntity.inventoryFull()) { // Kaiiju - airplane
|
||||||
|
flag |= booleansupplier.getAsBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -456,11 +480,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isFullContainer(Container inventory, Direction direction) {
|
||||||
|
- return allMatch(inventory, direction, STACK_SIZE_TEST); // Paper - no streams
|
||||||
|
+ return inventory.isCompletelyFull(direction); // Kaiiju - airplane - use bitsets
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isEmptyContainer(Container inv, Direction facing) {
|
||||||
|
- return allMatch(inv, facing, IS_EMPTY_TEST);
|
||||||
|
+ return inv.isCompletelyEmpty(facing); // Kaiiju - airplane - use bitsets
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean suckInItems(Level world, Hopper hopper) {
|
||||||
|
@@ -650,7 +674,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
|
||||||
|
if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) {
|
||||||
|
boolean flag = false;
|
||||||
|
- boolean flag1 = to.isEmpty();
|
||||||
|
+ boolean flag1 = to.isCompletelyEmpty(side); // Kaiiju - airplane - use bitsets
|
||||||
|
|
||||||
|
if (itemstack1.isEmpty()) {
|
||||||
|
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||||
|
@@ -845,7 +869,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setItems(NonNullList<ItemStack> list) {
|
||||||
|
- this.items = list;
|
||||||
|
+ // Kaiiju start - airplane - use ItemListWithBitset
|
||||||
|
+ this.optimizedItems = dev.kaiijumc.kaiiju.structs.ItemListWithBitset.fromList(list);
|
||||||
|
+ this.items = this.optimizedItems.nonNullList;
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||||
|
index 081691f9710ff1115e4308f79ed49fbc38941193..648e28c5fba5c62e65f83fbb5ebc8836ffb166a9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||||
|
@@ -95,14 +95,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
this.unpackLootTable((Player)null);
|
||||||
|
- // Paper start
|
||||||
|
- for (final ItemStack itemStack : this.getItems()) {
|
||||||
|
- if (!itemStack.isEmpty()) {
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- return true;
|
||||||
|
- // Paper end
|
||||||
|
+ return this.isCompletelyEmpty(null); // Kaiiju - airplane - use super
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
Date: Fri, 10 Feb 2023 02:58:46 +0200
|
Date: Fri, 10 Feb 2023 02:58:46 +0200
|
||||||
Subject: [PATCH] Kaiiju Rebranding
|
Subject: [PATCH] Rebranding
|
||||||
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
index dd53b1ffaff8dbaea0cf21c489a90162a496a026..6dd416f65755ca0542e6661b8716672264120d59 100644
|
index 0dbcd376ab443af4853f0a02612866d71c5e9164..b374c8caf62db3e1325a3cb01bdd890a835541af 100644
|
||||||
--- a/build.gradle.kts
|
--- a/build.gradle.kts
|
||||||
+++ b/build.gradle.kts
|
+++ b/build.gradle.kts
|
||||||
@@ -8,7 +8,7 @@ plugins {
|
@@ -14,7 +14,7 @@ val alsoShade: Configuration by configurations.creating
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Folia start
|
// Folia start
|
||||||
@@ -17,7 +17,7 @@ index dd53b1ffaff8dbaea0cf21c489a90162a496a026..6dd416f65755ca0542e6661b87166722
|
|||||||
implementation("io.papermc.paper:paper-mojangapi:1.19.3-R0.1-SNAPSHOT") {
|
implementation("io.papermc.paper:paper-mojangapi:1.19.3-R0.1-SNAPSHOT") {
|
||||||
exclude("io.papermc.paper", "paper-api")
|
exclude("io.papermc.paper", "paper-api")
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ tasks.jar {
|
@@ -76,7 +76,7 @@ tasks.jar {
|
||||||
attributes(
|
attributes(
|
||||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||||
"Implementation-Title" to "CraftBukkit",
|
"Implementation-Title" to "CraftBukkit",
|
||||||
@@ -27,7 +27,7 @@ index dd53b1ffaff8dbaea0cf21c489a90162a496a026..6dd416f65755ca0542e6661b87166722
|
|||||||
"Specification-Title" to "Bukkit",
|
"Specification-Title" to "Bukkit",
|
||||||
"Specification-Version" to project.version,
|
"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
|
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||||
index 58dc84b7b3b04c2d0b00fc5fac5303d3378b3467..a128b1fabd4aadfe26a8375903c0451d7a65983a 100644
|
index cb60d58d4a7556dd896f31d0cd249f860bb3ef84..c9ccc016044f2b179c291d9d5b2a43967cca119a 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||||
@@ -593,7 +593,7 @@ public class Metrics {
|
@@ -593,7 +593,7 @@ public class Metrics {
|
||||||
@@ -48,15 +48,14 @@ index 58dc84b7b3b04c2d0b00fc5fac5303d3378b3467..a128b1fabd4aadfe26a8375903c0451d
|
|||||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
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
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
index 719b0e318a85d4a1fb8f616deeb31193495b462e..751b2bc79d29cb21c38cf5d35e3711149ec7b011 100644
|
index e2f704c115fd6e00960bb56bb0779f1100c89c17..95bc514df2022dde265b84490d3d0db002685024 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
@@ -19,10 +19,11 @@ import java.util.stream.StreamSupport;
|
@@ -20,9 +20,11 @@ import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
public class PaperVersionFetcher implements VersionFetcher {
|
public class PaperVersionFetcher implements VersionFetcher {
|
||||||
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||||
- private static final String GITHUB_BRANCH_NAME = "master";
|
private static final String GITHUB_BRANCH_NAME = "master";
|
||||||
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
|
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads/paper";
|
||||||
+ // Kaiiju start
|
+ // Kaiiju start
|
||||||
+ private static final String DOWNLOAD_PAGE = "https://github.com/KaiijuMC/Kaiiju/releases";
|
+ private static final String DOWNLOAD_PAGE = "https://github.com/KaiijuMC/Kaiiju/releases";
|
||||||
+ private static int distance = -2; public int distance() { return distance; }
|
+ private static int distance = -2; public int distance() { return distance; }
|
||||||
@@ -66,7 +65,7 @@ index 719b0e318a85d4a1fb8f616deeb31193495b462e..751b2bc79d29cb21c38cf5d35e371114
|
|||||||
@Override
|
@Override
|
||||||
public long getCacheTime() {
|
public long getCacheTime() {
|
||||||
return 720000;
|
return 720000;
|
||||||
@@ -31,8 +32,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
@@ -31,8 +33,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Component getVersionMessage(@Nonnull String serverVersion) {
|
public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||||
@@ -77,7 +76,7 @@ index 719b0e318a85d4a1fb8f616deeb31193495b462e..751b2bc79d29cb21c38cf5d35e371114
|
|||||||
final Component history = getHistory();
|
final Component history = getHistory();
|
||||||
|
|
||||||
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
||||||
@@ -45,7 +46,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
@@ -45,7 +47,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
String result = matcher.group();
|
String result = matcher.group();
|
||||||
mcVer = result.substring(0, result.length() - 2); // strip 'R' anchor and trailing '-'
|
mcVer = result.substring(0, result.length() - 2); // strip 'R' anchor and trailing '-'
|
||||||
} else {
|
} else {
|
||||||
@@ -86,19 +85,19 @@ index 719b0e318a85d4a1fb8f616deeb31193495b462e..751b2bc79d29cb21c38cf5d35e371114
|
|||||||
org.bukkit.Bukkit.getLogger().warning("Pattern: " + VER_PATTERN.toString());
|
org.bukkit.Bukkit.getLogger().warning("Pattern: " + VER_PATTERN.toString());
|
||||||
org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion());
|
org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion());
|
||||||
}
|
}
|
||||||
@@ -56,6 +57,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
@@ -56,6 +58,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
|
|
||||||
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||||
int distance;
|
int distance;
|
||||||
+ // Kaiiju start - disable jenkins/api checking
|
+ /* // Kaiiju - disable jenkins/api checking
|
||||||
+ /*
|
|
||||||
try {
|
try {
|
||||||
int jenkinsBuild = Integer.parseInt(versionInfo);
|
int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||||
distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
|
distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
|
||||||
@@ -63,6 +66,10 @@ public class PaperVersionFetcher implements VersionFetcher {
|
@@ -63,6 +66,11 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
versionInfo = versionInfo.replace("\"", "");
|
versionInfo = versionInfo.replace("\"", "");
|
||||||
distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||||
}
|
}
|
||||||
|
+ // Kaiiju start - disable jenkins/api checking
|
||||||
+ */
|
+ */
|
||||||
+ versionInfo = versionInfo.replace("\"", "");
|
+ versionInfo = versionInfo.replace("\"", "");
|
||||||
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||||
@@ -120,7 +119,7 @@ index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..1c7b5d91e914efbcfb50c6137c776078
|
|||||||
.completer(new ConsoleCommandCompleter(this.server))
|
.completer(new ConsoleCommandCompleter(this.server))
|
||||||
.option(LineReader.Option.COMPLETE_IN_WORD, true);
|
.option(LineReader.Option.COMPLETE_IN_WORD, true);
|
||||||
diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java
|
diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java
|
||||||
index abe37c7c3c6f5ab73afd738ec78f06d7e4d2ed96..52fc6bb99f6024273c7438d01314b576da66bd1a 100644
|
index 1d714d3eff11ed14f218656008190017494d4830..d39859f19afc4372999782a209f3836c6397f6d2 100644
|
||||||
--- a/src/main/java/net/minecraft/CrashReport.java
|
--- a/src/main/java/net/minecraft/CrashReport.java
|
||||||
+++ b/src/main/java/net/minecraft/CrashReport.java
|
+++ b/src/main/java/net/minecraft/CrashReport.java
|
||||||
@@ -125,7 +125,7 @@ public class CrashReport {
|
@@ -125,7 +125,7 @@ public class CrashReport {
|
||||||
@@ -133,10 +132,10 @@ index abe37c7c3c6f5ab73afd738ec78f06d7e4d2ed96..52fc6bb99f6024273c7438d01314b576
|
|||||||
stringbuilder.append(CrashReport.DATE_TIME_FORMATTER.format(ZonedDateTime.now()));
|
stringbuilder.append(CrashReport.DATE_TIME_FORMATTER.format(ZonedDateTime.now()));
|
||||||
stringbuilder.append("\n");
|
stringbuilder.append("\n");
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
index f5721f6d719b7055fdccc81d5e67ed758e90cb10..0696ad97437726fd6a13badfe7db0617dfbfb1ad 100644
|
index 2f2a8a0c05024115f3b7bd69ae400fadff2f36c5..4d13cfdb642a67a5db20b1567868f24a37d949c3 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -999,7 +999,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -982,7 +982,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
shutdownThread = Thread.currentThread();
|
shutdownThread = Thread.currentThread();
|
||||||
org.spigotmc.WatchdogThread.doStop(); // Paper
|
org.spigotmc.WatchdogThread.doStop(); // Paper
|
||||||
if (false && !isSameThread()) { // Folia - region threading
|
if (false && !isSameThread()) { // Folia - region threading
|
||||||
@@ -155,10 +154,10 @@ index f5721f6d719b7055fdccc81d5e67ed758e90cb10..0696ad97437726fd6a13badfe7db0617
|
|||||||
|
|
||||||
public SystemReport fillSystemReport(SystemReport details) {
|
public SystemReport fillSystemReport(SystemReport details) {
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index 32c9b38036052649b7b5fb25d7c4a49fdd1ca972..176f3acec268dad80cc90029edd88e7a0c3e8885 100644
|
index a50a9ffda4875061fb8840873115119f334f0519..66723512de9b9fc92cdeeabb2cf96aa5fad10aaa 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@@ -256,7 +256,7 @@ import javax.annotation.Nullable; // Paper
|
@@ -267,7 +267,7 @@ import javax.annotation.Nullable; // Paper
|
||||||
import javax.annotation.Nonnull; // Paper
|
import javax.annotation.Nonnull; // Paper
|
||||||
|
|
||||||
public final class CraftServer implements Server {
|
public final class CraftServer implements Server {
|
||||||
@@ -168,10 +167,10 @@ index 32c9b38036052649b7b5fb25d7c4a49fdd1ca972..176f3acec268dad80cc90029edd88e7a
|
|||||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||||
private final Logger logger = Logger.getLogger("Minecraft");
|
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
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||||
index bd115a08512e6f4c13bc30ce2b05c7378754754f..d1b0483448a42f2d790eae353904bf6890178e1b 100644
|
index 28062755016008d0796676119fdd53d4a3947e20..b4d25d15797d37e644e85c5d2ba6211434a1ecbe 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||||
@@ -891,7 +891,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
@@ -920,7 +920,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||||
return EntityCategory.WATER;
|
return EntityCategory.WATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,13 +180,13 @@ index bd115a08512e6f4c13bc30ce2b05c7378754754f..d1b0483448a42f2d790eae353904bf68
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||||
index 9136fb30db749737e9f189d0901024fcad02e402..ac23657071ac5eb951706374ee16a4274728c5bd 100644
|
index eb84a8dd97f92de4a7dd3826d9e124a442cba565..e24d653fafcd88e01786b77539c506bcf3751c2c 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||||
@@ -504,7 +504,7 @@ public class CraftScheduler implements BukkitScheduler {
|
@@ -501,7 +501,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||||
this.parsePending();
|
this.parsePending();
|
||||||
} else {
|
} else {
|
||||||
//this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper
|
// this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper
|
||||||
- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Paper"); // Paper
|
- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Paper"); // Paper
|
||||||
+ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Kaiiju"); // Paper // Kaiiju
|
+ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Kaiiju"); // Paper // Kaiiju
|
||||||
// We don't need to parse pending
|
// We don't need to parse pending
|
||||||
@@ -207,7 +206,7 @@ index e9b6ca3aa25e140467ae866d572483050ea3fa0e..5df2b0fceebaaa863f4f143c8f29e808
|
|||||||
|
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||||
index e9fa7faaa4451e36b3908cbcbbe0baf213abde96..eea30035f7ce41f8f3c60afbbd255ae42166a306 100644
|
index 50c72e5db369a180f425eaaa0411cb8871bc3463..c556a1368ca089aad9d7f2f422924fea140e728d 100644
|
||||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
||||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||||
@@ -155,14 +155,14 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
@@ -155,14 +155,14 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
Date: Fri, 10 Feb 2023 05:53:10 +0200
|
Date: Fri, 10 Feb 2023 05:53:10 +0200
|
||||||
Subject: [PATCH] Kaiiju Configuration
|
Subject: [PATCH] Empty configuration
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
@@ -207,7 +207,7 @@ index 0000000000000000000000000000000000000000..7da7e0aeb5eac9ac73a3570e716f1ceb
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19
|
index 0000000000000000000000000000000000000000..87ca934473f3b9553c1b9b3ed60e0fa07838c711
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
@@ -0,0 +1,125 @@
|
@@ -0,0 +1,125 @@
|
||||||
@@ -336,13 +336,12 @@ index 0000000000000000000000000000000000000000..dd4c3ca77acb3aeefc69b8eb948b8b20
|
|||||||
+ return value.isEmpty() ? fallback : value;
|
+ return value.isEmpty() ? fallback : value;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
\ No newline at end of file
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java b/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java b/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..08a2375b90a2088e2bdfb3e316144677346a3dd6
|
index 0000000000000000000000000000000000000000..6fac162e0ec057af9f3336314d5663554cef0490
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
||||||
@@ -0,0 +1,67 @@
|
@@ -0,0 +1,66 @@
|
||||||
+package dev.kaiijumc.kaiiju.command;
|
+package dev.kaiijumc.kaiiju.command;
|
||||||
+
|
+
|
||||||
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
||||||
@@ -381,16 +380,15 @@ index 0000000000000000000000000000000000000000..08a2375b90a2088e2bdfb3e316144677
|
|||||||
+ @Override
|
+ @Override
|
||||||
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||||
+ if (!testPermission(sender)) return true;
|
+ if (!testPermission(sender)) return true;
|
||||||
+ String prefix = ChatColor.of(Color.decode("#F25DF6")) + "Kaiiju » " + ChatColor.RESET;
|
|
||||||
+
|
+
|
||||||
+ if (args.length != 1) {
|
+ if (args.length != 1) {
|
||||||
+ sender.sendMessage(prefix + ChatColor.RED + "Usage: " + usageMessage);
|
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (args[0].equalsIgnoreCase("reload")) {
|
+ if (args[0].equalsIgnoreCase("reload")) {
|
||||||
+ Command.broadcastCommandMessage(sender, prefix + ChatColor.RED + "Please note that this command is not supported and may cause issues.");
|
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
|
||||||
+ Command.broadcastCommandMessage(sender, prefix + ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||||
+
|
+
|
||||||
+ MinecraftServer console = MinecraftServer.getServer();
|
+ MinecraftServer console = MinecraftServer.getServer();
|
||||||
+ KaiijuConfig.reload((File) console.options.valueOf("kaiiju-settings"));
|
+ KaiijuConfig.reload((File) console.options.valueOf("kaiiju-settings"));
|
||||||
@@ -399,7 +397,7 @@ index 0000000000000000000000000000000000000000..08a2375b90a2088e2bdfb3e316144677
|
|||||||
+ }
|
+ }
|
||||||
+ console.server.reloadCount++;
|
+ console.server.reloadCount++;
|
||||||
+
|
+
|
||||||
+ Command.broadcastCommandMessage(sender, prefix + ChatColor.GREEN + "Kaiiju config reload complete.");
|
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Kaiiju config reload complete.");
|
||||||
+ } else if (args[0].equalsIgnoreCase("version")) {
|
+ } else if (args[0].equalsIgnoreCase("version")) {
|
||||||
+ Command verCmd = org.bukkit.Bukkit.getServer().getCommandMap().getCommand("version");
|
+ Command verCmd = org.bukkit.Bukkit.getServer().getCommandMap().getCommand("version");
|
||||||
+ if (verCmd != null) {
|
+ if (verCmd != null) {
|
||||||
@@ -412,7 +410,7 @@ index 0000000000000000000000000000000000000000..08a2375b90a2088e2bdfb3e316144677
|
|||||||
+}
|
+}
|
||||||
\ No newline at end of file
|
\ 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
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
index 7abd4f38ae59a6019137345af960fd60a3c7adf0..426777730f77664c69bd0a084a9323d767ebc0ad 100644
|
index a9fe3d1c0fc217bd32e884c9e75c906d8b4bf967..dcf8fd8ab06b10ecffae7332bc7e1a941b6a27a1 100644
|
||||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
@@ -218,6 +218,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
@@ -218,6 +218,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||||
@@ -432,10 +430,10 @@ index 7abd4f38ae59a6019137345af960fd60a3c7adf0..426777730f77664c69bd0a084a9323d7
|
|||||||
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
||||||
// Paper end
|
// Paper end
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
index c7c682cd2d1498e6d6521ddd62acdc1168bfe152..53b9444ff6120628d23ad27fc87d9cd9bdf66648 100644
|
index 0ff6764c747ee6258ab9d722b48c24f0ddb2afdf..08f9e5d89a56c50d477437bd8ff15758fc7621cc 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
@@ -167,6 +167,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -166,6 +166,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
|
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
|
||||||
@@ -444,7 +442,7 @@ index c7c682cd2d1498e6d6521ddd62acdc1168bfe152..53b9444ff6120628d23ad27fc87d9cd9
|
|||||||
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
|
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
|
||||||
public static BlockPos lastPhysicsProblem; // Spigot
|
public static BlockPos lastPhysicsProblem; // Spigot
|
||||||
private org.spigotmc.TickLimiter entityLimiter;
|
private org.spigotmc.TickLimiter entityLimiter;
|
||||||
@@ -294,6 +296,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -233,6 +235,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
|
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
|
||||||
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
||||||
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
|
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
|
||||||
@@ -453,10 +451,10 @@ index c7c682cd2d1498e6d6521ddd62acdc1168bfe152..53b9444ff6120628d23ad27fc87d9cd9
|
|||||||
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
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
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index b1680507c05547458e1199412ab97105b67f8973..d1468cb0ae1850719d40524dad9b14fbdb0f79a1 100644
|
index 66723512de9b9fc92cdeeabb2cf96aa5fad10aaa..86148da7878e8cf832eff299cbb3120a7a385a4f 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@@ -1067,6 +1067,7 @@ public final class CraftServer implements Server {
|
@@ -1080,6 +1080,7 @@ public final class CraftServer implements Server {
|
||||||
|
|
||||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||||
@@ -464,7 +462,7 @@ index b1680507c05547458e1199412ab97105b67f8973..d1468cb0ae1850719d40524dad9b14fb
|
|||||||
for (ServerLevel world : this.console.getAllLevels()) {
|
for (ServerLevel world : this.console.getAllLevels()) {
|
||||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
// 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))
|
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||||
@@ -1082,6 +1083,7 @@ public final class CraftServer implements Server {
|
@@ -1095,6 +1096,7 @@ public final class CraftServer implements Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
world.spigotConfig.init(); // Spigot
|
world.spigotConfig.init(); // Spigot
|
||||||
@@ -472,7 +470,7 @@ index b1680507c05547458e1199412ab97105b67f8973..d1468cb0ae1850719d40524dad9b14fb
|
|||||||
}
|
}
|
||||||
|
|
||||||
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
||||||
@@ -1097,6 +1099,7 @@ public final class CraftServer implements Server {
|
@@ -1110,6 +1112,7 @@ public final class CraftServer implements Server {
|
||||||
this.reloadData();
|
this.reloadData();
|
||||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||||
@@ -480,7 +478,7 @@ index b1680507c05547458e1199412ab97105b67f8973..d1468cb0ae1850719d40524dad9b14fb
|
|||||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||||
|
|
||||||
@@ -2857,6 +2860,13 @@ public final class CraftServer implements Server {
|
@@ -2957,6 +2960,13 @@ public final class CraftServer implements Server {
|
||||||
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,7 +493,7 @@ index b1680507c05547458e1199412ab97105b67f8973..d1468cb0ae1850719d40524dad9b14fb
|
|||||||
public void restart() {
|
public void restart() {
|
||||||
org.spigotmc.RestartCommand.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
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
index 4966a1e3dd35357a8ea6a7d2944c84c9c3e9058e..79a004dda72365afddb80fcd730828e351d7cce1 100644
|
index e4cacb17f56c618bef19e1165c07aac86af61150..d29fe7ac0c68b2d57a0c6b6d06bbb4436bfc4c14 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
@@ -173,6 +173,14 @@ public class Main {
|
@@ -173,6 +173,14 @@ public class Main {
|
||||||
@@ -1,29 +1,30 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
Date: Fri, 10 Feb 2023 20:03:58 +0200
|
Date: Fri, 10 Feb 2023 20:03:58 +0200
|
||||||
Subject: [PATCH] Kaiiju RegionFormat Configuration
|
Subject: [PATCH] Region format configuration
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..b86c90cc3601e666998cfa12f44515f605bb53eb 100644
|
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..f08bcc9ae1770fa847d8a5e873a554bef5485100 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
@@ -192,4 +192,10 @@ public class KaiijuConfig {
|
@@ -192,4 +192,7 @@ public class KaiijuConfig {
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ public static boolean regionFormatDebug = false;
|
|
||||||
+
|
|
||||||
+ private static void regionFormatSettings() {
|
+ 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
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..b194f4dbebcbbf5bb4e026a0169e2d24806b46ec 100644
|
index 87ca934473f3b9553c1b9b3ed60e0fa07838c711..a6e7af5f4148e067660e9f5beeacde3a59a1de9c 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
+++ b/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;
|
@@ -1,12 +1,15 @@
|
||||||
|
package dev.kaiijumc.kaiiju;
|
||||||
|
|
||||||
|
+import dev.kaiijumc.kaiiju.region.RegionFileFormat;
|
||||||
|
import org.apache.commons.lang.BooleanUtils;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
@@ -35,21 +36,20 @@ index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..b194f4dbebcbbf5bb4e026a0169e2d24
|
|||||||
|
|
||||||
import static dev.kaiijumc.kaiiju.KaiijuConfig.log;
|
import static dev.kaiijumc.kaiiju.KaiijuConfig.log;
|
||||||
|
|
||||||
@@ -122,4 +124,23 @@ public class KaiijuWorldConfig {
|
@@ -122,4 +125,22 @@ public class KaiijuWorldConfig {
|
||||||
final Map<String, Object> value = getMap("world-settings." + worldName + "." + path, null);
|
final Map<String, Object> value = getMap("world-settings." + worldName + "." + path, null);
|
||||||
return value.isEmpty() ? fallback : value;
|
return value.isEmpty() ? fallback : value;
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ public List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
|
+ public RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
||||||
+ public String regionFormatName = "ANVIL";
|
|
||||||
+ public int regionFormatLinearCompressionLevel = 1;
|
+ public int regionFormatLinearCompressionLevel = 1;
|
||||||
+
|
+
|
||||||
+ private void regionFormatSettings() {
|
+ private void regionFormatSettings() {
|
||||||
+ regionFormatName = getString("region-format.format", regionFormatName).toUpperCase();
|
+ regionFormatName = RegionFileFormat.fromString(getString("region-format.format", regionFormatName.name()));
|
||||||
+ if (!regionFormatList.contains(regionFormatName)) {
|
+ if (regionFormatName.equals(RegionFileFormat.INVALID)) {
|
||||||
+ log(Level.SEVERE, "Unknown region format in kaiiju.yml: " + regionFormatName);
|
+ log(Level.SEVERE, "Unknown region format in kaiiju.yml: " + regionFormatName);
|
||||||
+ log(Level.SEVERE, "Falling back to ANVIL region file format.");
|
+ log(Level.SEVERE, "Falling back to ANVIL region file format.");
|
||||||
+ regionFormatName = "ANVIL";
|
+ regionFormatName = RegionFileFormat.ANVIL;
|
||||||
+ }
|
+ }
|
||||||
+ regionFormatLinearCompressionLevel = getInt("region-format.linear.compression-level", regionFormatLinearCompressionLevel);
|
+ regionFormatLinearCompressionLevel = getInt("region-format.linear.compression-level", regionFormatLinearCompressionLevel);
|
||||||
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
|
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
|
||||||
@@ -59,12 +59,33 @@ index dd4c3ca77acb3aeefc69b8eb948b8b202ff87a19..b194f4dbebcbbf5bb4e026a0169e2d24
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
\ No newline at end of file
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java b/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..7164d9cd03186f0657783f83de3d6435cda2b17e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java
|
||||||
|
@@ -0,0 +1,16 @@
|
||||||
|
+package dev.kaiijumc.kaiiju.region;
|
||||||
|
+
|
||||||
|
+public enum RegionFileFormat {
|
||||||
|
+ ANVIL,
|
||||||
|
+ LINEAR,
|
||||||
|
+ INVALID;
|
||||||
|
+
|
||||||
|
+ public static RegionFileFormat fromString(String format) {
|
||||||
|
+ for (RegionFileFormat rff : values()) {
|
||||||
|
+ if (rff.name().equalsIgnoreCase(format)) {
|
||||||
|
+ return rff;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return RegionFileFormat.INVALID;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
index 0696ad97437726fd6a13badfe7db0617dfbfb1ad..a7233bcc99e9bf148348ebb36bbb15b2eadb381f 100644
|
index 356f1fd44df5a9cf77655f788650415cadab53e1..84242c7cdbeccda4c9a23e0376daf80ce221e504 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -897,7 +897,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -880,7 +880,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
// Paper start - rewrite chunk system
|
// Paper start - rewrite chunk system
|
||||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force, close);
|
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force, close);
|
||||||
if (flush) {
|
if (flush) {
|
||||||
@@ -73,7 +94,7 @@ index 0696ad97437726fd6a13badfe7db0617dfbfb1ad..a7233bcc99e9bf148348ebb36bbb15b2
|
|||||||
}
|
}
|
||||||
// Paper end - rewrite chunk system
|
// Paper end - rewrite chunk system
|
||||||
}
|
}
|
||||||
@@ -921,7 +921,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -904,7 +904,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
//MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); // Paper - move up
|
//MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); // Paper - move up
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,15 +1,18 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
Date: Fri, 10 Feb 2023 22:21:56 +0200
|
Date: Fri, 10 Feb 2023 22:21:56 +0200
|
||||||
Subject: [PATCH] Kaiiju RegionFormat Linear
|
Subject: [PATCH] Add Linear region format
|
||||||
|
|
||||||
|
Linear is a region file format that uses ZSTD compression instead of
|
||||||
|
ZLIB.
|
||||||
|
This format saves about 50% of disk space.
|
||||||
Documentation: https://github.com/xymb-endcrystalme/LinearRegionFileFormatTools
|
Documentation: https://github.com/xymb-endcrystalme/LinearRegionFileFormatTools
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
index 6dd416f65755ca0542e6661b8716672264120d59..4686019a152114e63e997ee103fc8424b24b4581 100644
|
index b374c8caf62db3e1325a3cb01bdd890a835541af..7dd84de137e863cfc20582c1451a03ef6e4e495a 100644
|
||||||
--- a/build.gradle.kts
|
--- a/build.gradle.kts
|
||||||
+++ b/build.gradle.kts
|
+++ b/build.gradle.kts
|
||||||
@@ -13,6 +13,10 @@ dependencies {
|
@@ -19,6 +19,10 @@ dependencies {
|
||||||
exclude("io.papermc.paper", "paper-api")
|
exclude("io.papermc.paper", "paper-api")
|
||||||
}
|
}
|
||||||
// Folia end
|
// Folia end
|
||||||
@@ -35,6 +38,34 @@ index f2c27e0ac65be4b75c1d86ef6fd45fdb538d96ac..00724993d0448454d14a47652b039b88
|
|||||||
|
|
||||||
public static final class InProgressWrite {
|
public static final class InProgressWrite {
|
||||||
public long writeCounter;
|
public long writeCounter;
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index f08bcc9ae1770fa847d8a5e873a554bef5485100..b7f43cce80742aa0cd523e930772ff84946f3eef 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -15,7 +15,6 @@ 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;
|
||||||
|
@@ -193,6 +192,15 @@ public class KaiijuConfig {
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public static int linearFlushFrequency = 10;
|
||||||
|
+ public static int linearFlushThreads = 1;
|
||||||
|
+
|
||||||
|
private static void regionFormatSettings() {
|
||||||
|
+ linearFlushFrequency = getInt("region-format.linear.flush-frequency", linearFlushFrequency);
|
||||||
|
+ linearFlushThreads = getInt("region-format.linear.flush-max-threads", linearFlushThreads);
|
||||||
|
+ if (linearFlushThreads < 0)
|
||||||
|
+ linearFlushThreads = Math.max(Runtime.getRuntime().availableProcessors() + linearFlushThreads, 1);
|
||||||
|
+ else
|
||||||
|
+ linearFlushThreads = Math.max(linearFlushThreads, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
|
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
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..249303116d3cfadd078ebf0ae6e44bf99eed6a47
|
index 0000000000000000000000000000000000000000..249303116d3cfadd078ebf0ae6e44bf99eed6a47
|
||||||
@@ -109,10 +140,10 @@ index 0000000000000000000000000000000000000000..dcfbabf54b19a4c29d5c95830242c5c2
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696d4cdd0cc
|
index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b033013904
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||||
@@ -0,0 +1,336 @@
|
@@ -0,0 +1,316 @@
|
||||||
+package dev.kaiijumc.kaiiju.region;
|
+package dev.kaiijumc.kaiiju.region;
|
||||||
+
|
+
|
||||||
+import com.github.luben.zstd.ZstdInputStream;
|
+import com.github.luben.zstd.ZstdInputStream;
|
||||||
@@ -133,235 +164,215 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+import java.nio.file.Path;
|
+import java.nio.file.Path;
|
||||||
+import java.nio.file.StandardCopyOption;
|
+import java.nio.file.StandardCopyOption;
|
||||||
+import java.util.ArrayList;
|
+import java.util.ArrayList;
|
||||||
|
+import java.util.Arrays;
|
||||||
|
+import java.util.List;
|
||||||
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
+import java.util.concurrent.locks.ReentrantLock;
|
+import java.util.concurrent.locks.ReentrantLock;
|
||||||
+
|
+
|
||||||
+public class LinearRegionFile extends Thread implements AbstractRegionFile {
|
+public class LinearRegionFile implements AbstractRegionFile, AutoCloseable {
|
||||||
|
+ private static final long SUPERBLOCK = -4323716122432332390L;
|
||||||
|
+ private static final byte VERSION = 2;
|
||||||
|
+ private static final int HEADER_SIZE = 32;
|
||||||
|
+ private static final int FOOTER_SIZE = 8;
|
||||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
+ private final byte[][] buffer = new byte[32*32][];
|
+ private static final List<Byte> SUPPORTED_VERSIONS = Arrays.asList((byte) 1, (byte) 2);
|
||||||
+ private final int[] bufferUncompressedSize = new int[32*32];
|
+ private static final LinearRegionFileFlusher linearRegionFileFlusher = new LinearRegionFileFlusher();
|
||||||
+
|
+
|
||||||
+ private final Object markedToSaveLock = new Object();
|
+ private final byte[][] buffer = new byte[1024][];
|
||||||
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
|
+ private final int[] bufferUncompressedSize = new int[1024];
|
||||||
+
|
+
|
||||||
+ private boolean markedToSave = false;
|
+ private final int[] chunkTimestamps = new int[1024];
|
||||||
+ private boolean close = false;
|
+ private final ChunkStatus[] statuses = new ChunkStatus[1024];
|
||||||
|
+
|
||||||
|
+ private final LZ4Compressor compressor;
|
||||||
|
+ private final LZ4FastDecompressor decompressor;
|
||||||
+
|
+
|
||||||
+ public final ReentrantLock fileLock = new ReentrantLock(true);
|
+ public final ReentrantLock fileLock = new ReentrantLock(true);
|
||||||
+ public Path regionFile;
|
|
||||||
+
|
|
||||||
+ private final int compressionLevel;
|
+ private final int compressionLevel;
|
||||||
+
|
+
|
||||||
|
+ private AtomicBoolean markedToSave = new AtomicBoolean(false);
|
||||||
|
+ public boolean closed = false;
|
||||||
|
+ public Path path;
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
||||||
|
+ this.path = file;
|
||||||
|
+ this.compressionLevel = compression;
|
||||||
|
+ this.compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||||
|
+ this.decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||||
|
+
|
||||||
|
+ File regionFile = new File(this.path.toString());
|
||||||
|
+
|
||||||
|
+ Arrays.fill(this.bufferUncompressedSize, 0);
|
||||||
|
+
|
||||||
|
+ if (!regionFile.canRead()) return;
|
||||||
|
+
|
||||||
|
+ try (FileInputStream fileStream = new FileInputStream(regionFile);
|
||||||
|
+ DataInputStream rawDataStream = new DataInputStream(fileStream)) {
|
||||||
|
+
|
||||||
|
+ long superBlock = rawDataStream.readLong();
|
||||||
|
+ if (superBlock != SUPERBLOCK)
|
||||||
|
+ throw new RuntimeException("Invalid superblock: " + superBlock + " in " + file);
|
||||||
|
+
|
||||||
|
+ byte version = rawDataStream.readByte();
|
||||||
|
+ if (!SUPPORTED_VERSIONS.contains(version))
|
||||||
|
+ throw new RuntimeException("Invalid version: " + version + " in " + file);
|
||||||
|
+
|
||||||
|
+ // Skip newestTimestamp (Long) + Compression level (Byte) + Chunk count (Short): Unused.
|
||||||
|
+ rawDataStream.skipBytes(11);
|
||||||
|
+
|
||||||
|
+ int dataCount = rawDataStream.readInt();
|
||||||
|
+ long fileLength = file.toFile().length();
|
||||||
|
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE)
|
||||||
|
+ throw new IOException("Invalid file length: " + this.path + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||||
|
+
|
||||||
|
+ rawDataStream.skipBytes(8); // Skip data hash (Long): Unused.
|
||||||
|
+
|
||||||
|
+ byte[] rawCompressed = new byte[dataCount];
|
||||||
|
+ rawDataStream.readFully(rawCompressed, 0, dataCount);
|
||||||
|
+
|
||||||
|
+ superBlock = rawDataStream.readLong();
|
||||||
|
+ if (superBlock != SUPERBLOCK)
|
||||||
|
+ throw new IOException("Footer superblock invalid " + this.path);
|
||||||
|
+
|
||||||
|
+ try (DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)))) {
|
||||||
|
+
|
||||||
|
+ int[] starts = new int[1024];
|
||||||
|
+ for (int i = 0; i < 1024; i++) {
|
||||||
|
+ starts[i] = dataStream.readInt();
|
||||||
|
+ dataStream.skipBytes(4); // Skip timestamps (Int): Unused.
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < 1024; i++) {
|
||||||
|
+ if (starts[i] > 0) {
|
||||||
|
+ int size = starts[i];
|
||||||
|
+ byte[] b = new byte[size];
|
||||||
|
+ dataStream.readFully(b, 0, size);
|
||||||
|
+
|
||||||
|
+ int maxCompressedLength = this.compressor.maxCompressedLength(size);
|
||||||
|
+ byte[] compressed = new byte[maxCompressedLength];
|
||||||
|
+ int compressedLength = this.compressor.compress(b, 0, size, compressed, 0, maxCompressedLength);
|
||||||
|
+ b = new byte[compressedLength];
|
||||||
|
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||||
|
+
|
||||||
|
+ this.buffer[i] = b;
|
||||||
|
+ this.bufferUncompressedSize[i] = size;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ public Path getRegionFile() {
|
+ public Path getRegionFile() {
|
||||||
+ return this.regionFile;
|
+ return this.path;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public ReentrantLock getFileLock() {
|
+ public ReentrantLock getFileLock() {
|
||||||
+ return this.fileLock;
|
+ return this.fileLock;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
+ public void flush() throws IOException {
|
||||||
+ this.regionFile = file;
|
+ if (isMarkedToSave()) flushWrapper(); // sync
|
||||||
+ this.compressionLevel = compression;
|
|
||||||
+ File regionFile = new File(this.regionFile.toString());
|
|
||||||
+
|
|
||||||
+ LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
|
|
||||||
+
|
|
||||||
+ for (int i = 0; i < 32 * 32; i++)
|
|
||||||
+ this.bufferUncompressedSize[i] = 0;
|
|
||||||
+
|
|
||||||
+ if(regionFile.canRead()) {
|
|
||||||
+ long fileLength = file.toFile().length();
|
|
||||||
+ FileInputStream fileStream = new FileInputStream(regionFile);
|
|
||||||
+ DataInputStream rawDataStream = new DataInputStream(fileStream);
|
|
||||||
+
|
|
||||||
+ long SUPERBLOCK = -4323716122432332390L;
|
|
||||||
+ byte VERSION = 1;
|
|
||||||
+ int HEADER_SIZE = 32;
|
|
||||||
+ int FOOTER_SIZE = 8;
|
|
||||||
+
|
|
||||||
+ long superBlock = rawDataStream.readLong();
|
|
||||||
+
|
|
||||||
+ if (superBlock != SUPERBLOCK)
|
|
||||||
+ throw new RuntimeException("Superblock invalid: " + superBlock + " file " + file);
|
|
||||||
+
|
|
||||||
+ byte version = rawDataStream.readByte();
|
|
||||||
+
|
|
||||||
+ 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 + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
|
||||||
+
|
|
||||||
+ rawDataStream.readLong(); // Data Hash
|
|
||||||
+ byte[] rawCompressed = new byte[dataCount];
|
|
||||||
+
|
|
||||||
+ rawDataStream.readFully(rawCompressed, 0, dataCount);
|
|
||||||
+
|
|
||||||
+ superBlock = rawDataStream.readLong();
|
|
||||||
+
|
|
||||||
+ if (superBlock != SUPERBLOCK) {
|
|
||||||
+ throw new IOException("Footer superblock invalid " + this.regionFile);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)));
|
|
||||||
+
|
|
||||||
+ int[] starts = new int[32 * 32];
|
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
|
||||||
+ starts[i] = dataStream.readInt();
|
|
||||||
+ dataStream.readInt(); // Skip timestamps
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
|
||||||
+ if(starts[i] > 0) {
|
|
||||||
+ int size = starts[i];
|
|
||||||
+ byte[] b = new byte[size];
|
|
||||||
+ dataStream.readFully(b, 0, size);
|
|
||||||
+
|
|
||||||
+ int maxCompressedLength = compressor.maxCompressedLength(size);
|
|
||||||
+ byte[] compressed = new byte[maxCompressedLength];
|
|
||||||
+ int compressedLength = compressor.compress(b, 0, size, compressed, 0, maxCompressedLength);
|
|
||||||
+ b = new byte[compressedLength];
|
|
||||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
|
||||||
+
|
|
||||||
+ this.buffer[i] = b;
|
|
||||||
+ this.bufferUncompressedSize[i] = size;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ this.start();
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private synchronized void markToSave() {
|
+ private void markToSave() {
|
||||||
+ synchronized(markedToSaveLock) {
|
+ linearRegionFileFlusher.scheduleSave(this);
|
||||||
+ markedToSave = true;
|
+ markedToSave.set(true);
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private synchronized boolean isMarkedToSave() {
|
+ public boolean isMarkedToSave() {
|
||||||
+ synchronized(markedToSaveLock) {
|
+ return markedToSave.getAndSet(false);
|
||||||
+ if(markedToSave) {
|
|
||||||
+ markedToSave = false;
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public void run() {
|
+ public void flushWrapper() {
|
||||||
+ try {
|
+ try {
|
||||||
+ while(true) {
|
+ save();
|
||||||
+ if(markedToSave) {
|
+ } catch (IOException e) {
|
||||||
+ try {
|
+ LOGGER.error("Failed to flush region file " + path.toAbsolutePath(), e);
|
||||||
+ flush();
|
+ }
|
||||||
+ } catch(IOException ex) {
|
|
||||||
+ LOGGER.error("Region file " + this.regionFile.toAbsolutePath() + " flush failed");
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ for(int i = 0 ; i < 100 ; i++) {
|
|
||||||
+ Thread.sleep(100);
|
|
||||||
+ if(close) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ } catch(InterruptedException ignored) {}
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public synchronized boolean doesChunkExist(ChunkPos pos) throws Exception {
|
+ public boolean doesChunkExist(ChunkPos pos) throws Exception {
|
||||||
+ throw new Exception("doesChunkExist is a stub");
|
+ throw new Exception("doesChunkExist is a stub");
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public synchronized void flush() throws IOException {
|
+ private synchronized void save() throws IOException {
|
||||||
+ if(!isMarkedToSave())
|
+ long timestamp = getTimestamp();
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ long SUPERBLOCK = -4323716122432332390L;
|
|
||||||
+ byte VERSION = 1;
|
|
||||||
+ long timestamp = System.currentTimeMillis() / 1000L;
|
|
||||||
+ short chunkCount = 0;
|
+ short chunkCount = 0;
|
||||||
+
|
+
|
||||||
+ File tempFile = new File(regionFile.toString() + ".tmp");
|
+ File tempFile = new File(path.toString() + ".tmp");
|
||||||
+ FileOutputStream fileStream = new FileOutputStream(tempFile);
|
|
||||||
+
|
+
|
||||||
+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream();
|
+ try (FileOutputStream fileStream = new FileOutputStream(tempFile);
|
||||||
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel);
|
+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream();
|
||||||
+ zstdStream.setChecksum(true);
|
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel);
|
||||||
+ DataOutputStream zstdDataStream = new DataOutputStream(zstdStream);
|
+ DataOutputStream zstdDataStream = new DataOutputStream(zstdStream);
|
||||||
+ DataOutputStream dataStream = new DataOutputStream(fileStream);
|
+ DataOutputStream dataStream = new DataOutputStream(fileStream)) {
|
||||||
+
|
+
|
||||||
+ dataStream.writeLong(SUPERBLOCK);
|
+ dataStream.writeLong(SUPERBLOCK);
|
||||||
+ dataStream.writeByte(VERSION);
|
+ dataStream.writeByte(VERSION);
|
||||||
+ dataStream.writeLong(timestamp);
|
+ dataStream.writeLong(timestamp);
|
||||||
+ dataStream.writeByte(this.compressionLevel);
|
+ dataStream.writeByte(this.compressionLevel);
|
||||||
+
|
+
|
||||||
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
|
||||||
|
+ for (int i = 0; i < 1024; i++) {
|
||||||
|
+ if (this.bufferUncompressedSize[i] != 0) {
|
||||||
|
+ chunkCount += 1;
|
||||||
|
+ byte[] content = new byte[bufferUncompressedSize[i]];
|
||||||
|
+ this.decompressor.decompress(buffer[i], 0, content, 0, bufferUncompressedSize[i]);
|
||||||
+
|
+
|
||||||
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
|
+ byteBuffers.add(content);
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
+ } else byteBuffers.add(null);
|
||||||
+ if(this.bufferUncompressedSize[i] != 0) {
|
+ }
|
||||||
+ chunkCount += 1;
|
+ for (int i = 0; i < 1024; i++) {
|
||||||
+ byte[] content = new byte[bufferUncompressedSize[i]];
|
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]); // Write uncompressed size
|
||||||
+ decompressor.decompress(buffer[i], 0, content, 0, bufferUncompressedSize[i]);
|
+ zstdDataStream.writeInt(this.chunkTimestamps[i]); // Write timestamp
|
||||||
|
+ }
|
||||||
|
+ for (int i = 0; i < 1024; i++) {
|
||||||
|
+ if (byteBuffers.get(i) != null)
|
||||||
|
+ zstdDataStream.write(byteBuffers.get(i), 0, byteBuffers.get(i).length);
|
||||||
|
+ }
|
||||||
|
+ zstdDataStream.close();
|
||||||
+
|
+
|
||||||
+ byteBuffers.add(content);
|
+ dataStream.writeShort(chunkCount);
|
||||||
+ } else byteBuffers.add(null);
|
+
|
||||||
|
+ byte[] compressed = zstdByteArray.toByteArray();
|
||||||
|
+
|
||||||
|
+ dataStream.writeInt(compressed.length);
|
||||||
|
+ dataStream.writeLong(0);
|
||||||
|
+
|
||||||
|
+ dataStream.write(compressed, 0, compressed.length);
|
||||||
|
+ dataStream.writeLong(SUPERBLOCK);
|
||||||
|
+
|
||||||
|
+ dataStream.flush();
|
||||||
|
+ fileStream.getFD().sync();
|
||||||
|
+ fileStream.getChannel().force(true); // Ensure atomicity on Btrfs
|
||||||
+ }
|
+ }
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
+ Files.move(tempFile.toPath(), this.path, StandardCopyOption.REPLACE_EXISTING);
|
||||||
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]);
|
|
||||||
+ zstdDataStream.writeInt(0);
|
|
||||||
+ }
|
|
||||||
+ for(int i = 0 ; i < 32 * 32 ; i++) {
|
|
||||||
+ if(byteBuffers.get(i) != null)
|
|
||||||
+ zstdDataStream.write(byteBuffers.get(i), 0, byteBuffers.get(i).length);
|
|
||||||
+ }
|
|
||||||
+ zstdDataStream.close();
|
|
||||||
+
|
|
||||||
+ dataStream.writeShort(chunkCount);
|
|
||||||
+
|
|
||||||
+ byte[] compressed = zstdByteArray.toByteArray();
|
|
||||||
+
|
|
||||||
+ dataStream.writeInt(compressed.length);
|
|
||||||
+ dataStream.writeLong(0);
|
|
||||||
+
|
|
||||||
+ dataStream.write(compressed, 0, compressed.length);
|
|
||||||
+ dataStream.writeLong(SUPERBLOCK);
|
|
||||||
+
|
|
||||||
+ dataStream.flush();
|
|
||||||
+ fileStream.getFD().sync();
|
|
||||||
+ fileStream.getChannel().force(true); // Ensure atomicity on Btrfs
|
|
||||||
+ dataStream.close();
|
|
||||||
+
|
|
||||||
+ fileStream.close();
|
|
||||||
+ Files.move(tempFile.toPath(), this.regionFile, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+
|
||||||
+ public void setStatus(int x, int z, ChunkStatus status) {
|
+ public void setStatus(int x, int z, ChunkStatus status) {
|
||||||
+ this.statuses[getChunkIndex(x, z)] = status;
|
+ this.statuses[getChunkIndex(x, z)] = status;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public synchronized void write(ChunkPos pos, ByteBuffer buffer) {
|
+ public synchronized void write(ChunkPos pos, ByteBuffer buffer) {
|
||||||
+ LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
|
|
||||||
+ try {
|
+ try {
|
||||||
+ byte[] b = toByteArray(new ByteArrayInputStream(buffer.array()));
|
+ byte[] b = toByteArray(new ByteArrayInputStream(buffer.array()));
|
||||||
+ int uncompressedSize = b.length;
|
+ int uncompressedSize = b.length;
|
||||||
+
|
+
|
||||||
+ int maxCompressedLength = compressor.maxCompressedLength(b.length);
|
+ int maxCompressedLength = this.compressor.maxCompressedLength(b.length);
|
||||||
+ byte[] compressed = new byte[maxCompressedLength];
|
+ byte[] compressed = new byte[maxCompressedLength];
|
||||||
+ int compressedLength = compressor.compress(b, 0, b.length, compressed, 0, maxCompressedLength);
|
+ int compressedLength = this.compressor.compress(b, 0, b.length, compressed, 0, maxCompressedLength);
|
||||||
+ b = new byte[compressedLength];
|
+ b = new byte[compressedLength];
|
||||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||||
+
|
+
|
||||||
+ this.buffer[getChunkIndex(pos.x, pos.z)] = b;
|
+ int index = getChunkIndex(pos.x, pos.z);
|
||||||
|
+ this.buffer[index] = b;
|
||||||
|
+ this.chunkTimestamps[index] = getTimestamp();
|
||||||
+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize;
|
+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize;
|
||||||
+ } catch (IOException e) {
|
+ } catch (IOException e) {
|
||||||
+ LOGGER.error("Chunk write IOException " + e + " " + this.regionFile);
|
+ LOGGER.error("Chunk write IOException " + e + " " + this.path);
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ markToSave();
|
+ markToSave();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@@ -370,7 +381,6 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private class ChunkBuffer extends ByteArrayOutputStream {
|
+ private class ChunkBuffer extends ByteArrayOutputStream {
|
||||||
+
|
|
||||||
+ private final ChunkPos pos;
|
+ private final ChunkPos pos;
|
||||||
+
|
+
|
||||||
+ public ChunkBuffer(ChunkPos chunkcoordintpair) {
|
+ public ChunkBuffer(ChunkPos chunkcoordintpair) {
|
||||||
@@ -399,9 +409,8 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ @Nullable
|
+ @Nullable
|
||||||
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
|
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
|
||||||
+ if(this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
|
+ if(this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
|
||||||
+ LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
|
||||||
+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]];
|
+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]];
|
||||||
+ decompressor.decompress(this.buffer[getChunkIndex(pos.x, pos.z)], 0, content, 0, bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]);
|
+ this.decompressor.decompress(this.buffer[getChunkIndex(pos.x, pos.z)], 0, content, 0, bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]);
|
||||||
+ return new DataInputStream(new ByteArrayInputStream(content));
|
+ return new DataInputStream(new ByteArrayInputStream(content));
|
||||||
+ }
|
+ }
|
||||||
+ return null;
|
+ return null;
|
||||||
@@ -415,6 +424,7 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ int i = getChunkIndex(pos.x, pos.z);
|
+ int i = getChunkIndex(pos.x, pos.z);
|
||||||
+ this.buffer[i] = null;
|
+ this.buffer[i] = null;
|
||||||
+ this.bufferUncompressedSize[i] = 0;
|
+ this.bufferUncompressedSize[i] = 0;
|
||||||
|
+ this.chunkTimestamps[i] = getTimestamp();
|
||||||
+ markToSave();
|
+ markToSave();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@@ -423,16 +433,17 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public void close() throws IOException {
|
+ public void close() throws IOException {
|
||||||
+ close = true;
|
+ if (closed) return;
|
||||||
+ try {
|
+ closed = true;
|
||||||
+ flush();
|
+ flush(); // sync
|
||||||
+ } catch(IOException e) {
|
|
||||||
+ throw new IOException("Region flush IOException " + e + " " + this.regionFile);
|
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static int getChunkIndex(int x, int z) {
|
+ private static int getChunkIndex(int x, int z) {
|
||||||
+ return (x & 31) + (z & 31) * 32;
|
+ return (x & 31) + ((z & 31) << 5);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static int getTimestamp() {
|
||||||
|
+ return (int) (System.currentTimeMillis() / 1000L);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public boolean recalculateHeader() {
|
+ public boolean recalculateHeader() {
|
||||||
@@ -442,13 +453,64 @@ index 0000000000000000000000000000000000000000..32213e1f2432a2ee0c27331e83a04696
|
|||||||
+ public void setOversized(int x, int z, boolean something) {}
|
+ public void setOversized(int x, int z, boolean something) {}
|
||||||
+
|
+
|
||||||
+ public CompoundTag getOversizedData(int x, int z) throws IOException {
|
+ public CompoundTag getOversizedData(int x, int z) throws IOException {
|
||||||
+ throw new IOException("getOversizedData is a stub " + this.regionFile);
|
+ throw new IOException("getOversizedData is a stub " + this.path);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public boolean isOversized(int x, int z) {
|
+ public boolean isOversized(int x, int z) {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..a5731e37aa63004476dd6db67191d5be6ce480be
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java
|
||||||
|
@@ -0,0 +1,45 @@
|
||||||
|
+package dev.kaiijumc.kaiiju.region;
|
||||||
|
+
|
||||||
|
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
+import java.util.Queue;
|
||||||
|
+import java.util.concurrent.*;
|
||||||
|
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+
|
||||||
|
+public class LinearRegionFileFlusher {
|
||||||
|
+ private final Queue<LinearRegionFile> savingQueue = new LinkedBlockingQueue<>();
|
||||||
|
+ private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(
|
||||||
|
+ new ThreadFactoryBuilder()
|
||||||
|
+ .setNameFormat("linear-flush-scheduler")
|
||||||
|
+ .build()
|
||||||
|
+ );
|
||||||
|
+ private final ExecutorService executor = Executors.newFixedThreadPool(
|
||||||
|
+ KaiijuConfig.linearFlushThreads,
|
||||||
|
+ new ThreadFactoryBuilder()
|
||||||
|
+ .setNameFormat("linear-flusher-%d")
|
||||||
|
+ .build()
|
||||||
|
+ );
|
||||||
|
+
|
||||||
|
+ public LinearRegionFileFlusher() {
|
||||||
|
+ Bukkit.getLogger().info("Using " + KaiijuConfig.linearFlushThreads + " threads for linear region flushing.");
|
||||||
|
+ scheduler.scheduleAtFixedRate(this::pollAndFlush, 0L, KaiijuConfig.linearFlushFrequency, TimeUnit.SECONDS);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void scheduleSave(LinearRegionFile regionFile) {
|
||||||
|
+ if (savingQueue.contains(regionFile)) return;
|
||||||
|
+ savingQueue.add(regionFile);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void pollAndFlush() {
|
||||||
|
+ while (!savingQueue.isEmpty()) {
|
||||||
|
+ LinearRegionFile regionFile = savingQueue.poll();
|
||||||
|
+ if (!regionFile.closed && regionFile.isMarkedToSave())
|
||||||
|
+ executor.execute(regionFile::flushWrapper);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void shutdown() {
|
||||||
|
+ executor.shutdown();
|
||||||
|
+ scheduler.shutdown();
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
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
|
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 8a11e10b01fa012b2f98b1c193c53251e848f909..61001e76b38f8647b33e73b5cc15b4b6785cf49a 100644
|
index 8a11e10b01fa012b2f98b1c193c53251e848f909..61001e76b38f8647b33e73b5cc15b4b6785cf49a 100644
|
||||||
--- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
--- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||||
@@ -517,16 +579,15 @@ index 8a11e10b01fa012b2f98b1c193c53251e848f909..61001e76b38f8647b33e73b5cc15b4b6
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
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
|
index 513833c2ea23df5b079d157bc5cb89d5c9754c0b..abf5e2a06af9853b58ac9107cd6e9787c4185c66 100644
|
||||||
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||||
+++ b/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 {
|
@@ -84,8 +84,13 @@ public class ThreadedWorldUpgrader {
|
||||||
}
|
|
||||||
LOGGER.info("Found " + regionFiles.length + " regionfiles to convert");
|
LOGGER.info("Found " + regionFiles.length + " regionfiles to convert");
|
||||||
LOGGER.info("Starting conversion now for world " + this.worldName);
|
LOGGER.info("Starting conversion now for world " + this.worldName);
|
||||||
-
|
|
||||||
+ // Kaiiju start
|
+ // Kaiiju start
|
||||||
+ String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
+ dev.kaiijumc.kaiiju.region.RegionFileFormat 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;
|
+ int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||||
+ LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
|
+ LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
|
||||||
+ // Kaiiju end
|
+ // Kaiiju end
|
||||||
@@ -537,11 +598,11 @@ index 513833c2ea23df5b079d157bc5cb89d5c9754c0b..a62a1b281bd0b6ad7d59b45b9470d84f
|
|||||||
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
index 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d640725dc0 100644
|
index 0f7e53dbac964391763bf6b380e65ce955a8a7a5..5868be332437cfa2cf21d48c02ba0bb73255b365 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
@@ -272,7 +272,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -210,7 +210,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
// Paper end
|
// Paper end - optimise chunk tick iteration
|
||||||
|
|
||||||
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) {
|
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(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
|
||||||
@@ -549,16 +610,16 @@ index 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d6
|
|||||||
// Paper - rewrite chunk system
|
// Paper - rewrite chunk system
|
||||||
this.tickingGenerated = new AtomicInteger();
|
this.tickingGenerated = new AtomicInteger();
|
||||||
//this.playerMap = new PlayerMap(); // Folia - region threading
|
//this.playerMap = new PlayerMap(); // Folia - region threading
|
||||||
@@ -317,7 +317,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -255,7 +255,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.lightEngine = new ThreadedLevelLightEngine(chunkProvider, this, this.level.dimensionType().hasSkyLight(), null, null); // Paper - rewrite chunk system
|
||||||
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
||||||
this.overworldDataStorage = persistentStateManagerFactory;
|
this.overworldDataStorage = persistentStateManagerFactory;
|
||||||
- this.poiManager = new PoiManager(path.resolve("poi"), dataFixer, dsync, iregistrycustom, world);
|
- 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.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||||
this.setViewDistance(viewDistance);
|
this.setServerViewDistance(viewDistance);
|
||||||
// Paper start
|
// Paper start
|
||||||
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
||||||
@@ -849,13 +849,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -818,13 +818,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
|
|
||||||
// Paper start - chunk status cache "api"
|
// Paper start - chunk status cache "api"
|
||||||
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
||||||
@@ -574,7 +635,7 @@ index 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d6
|
|||||||
|
|
||||||
if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
|
if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -873,7 +873,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -842,7 +842,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException {
|
public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException {
|
||||||
@@ -584,22 +645,21 @@ index 6f12d91f73e04c25fb0bc9054dc7d49de16e614a..43503974433c4d1808b2acb2b79f46d6
|
|||||||
regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkSerializer.getStatus(compound));
|
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
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
index acc8af33ad8534d812908b0feb9a1963ee2c64fb..20359c63b19c7e0c703ef1562fb774803d631c41 100644
|
index 02937e40d429f42643f77b17c04277be535dc434..3e2c14b9acc9e5bec70055646387b51f0be43105 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -425,9 +425,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -451,8 +451,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 {
|
private static final class EntityRegionFileStorage extends net.minecraft.world.level.chunk.storage.RegionFileStorage {
|
||||||
-
|
|
||||||
- public EntityRegionFileStorage(Path directory, boolean dsync) {
|
- public EntityRegionFileStorage(Path directory, boolean dsync) {
|
||||||
- super(directory, dsync);
|
- super(directory, dsync);
|
||||||
+ public EntityRegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
+ public EntityRegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
||||||
+ super(format, linearCompression, directory, dsync); // Kaiiju
|
+ super(format, linearCompression, directory, dsync); // Kaiiju
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
|
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
|
||||||
@@ -633,7 +632,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -808,7 +808,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||||
@@ -609,35 +669,34 @@ index acc8af33ad8534d812908b0feb9a1963ee2c64fb..20359c63b19c7e0c703ef1562fb77480
|
|||||||
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
|
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
|
||||||
StructureTemplateManager structuretemplatemanager = minecraftserver.getStructureManager();
|
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
|
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||||
index e0bfeebeaac1aaea64bc07cdfdf7790e3e43ca7b..469802b9c454c5e98c0a55ba89559d9d8ba0c4c0 100644
|
index e16ef1b7c0bfe6d6194c09f6787a50fd9b28f55e..3b02b7905fd16be28ba986302c1f99dfb5eb2ab8 100644
|
||||||
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||||
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||||
@@ -61,7 +61,7 @@ public class WorldUpgrader {
|
@@ -61,7 +61,7 @@ public class WorldUpgrader {
|
||||||
private volatile int skipped;
|
private volatile int skipped;
|
||||||
private final Object2FloatMap<ResourceKey<LevelStem>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy())); // CraftBukkit
|
private final Object2FloatMap<ResourceKey<Level>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy()));
|
||||||
private volatile Component status = Component.translatable("optimizeWorld.stage.counting");
|
private volatile Component status = Component.translatable("optimizeWorld.stage.counting");
|
||||||
- public static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
- public static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||||
+ public static Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // Kaiiju
|
+ public static Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // Kaiiju
|
||||||
private final DimensionDataStorage overworldDataStorage;
|
private final DimensionDataStorage overworldDataStorage;
|
||||||
|
|
||||||
public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, Registry<LevelStem> dimensionOptionsRegistry, boolean eraseCache) {
|
public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, Registry<LevelStem> dimensionOptionsRegistry, boolean eraseCache) {
|
||||||
@@ -115,8 +115,12 @@ public class WorldUpgrader {
|
@@ -116,7 +116,12 @@ public class WorldUpgrader {
|
||||||
while (iterator1.hasNext()) {
|
ResourceKey<Level> resourcekey1 = (ResourceKey) iterator1.next();
|
||||||
ResourceKey<LevelStem> resourcekey1 = (ResourceKey) iterator1.next(); // CraftBukkit
|
Path path = this.levelStorage.getDimensionPath(resourcekey1);
|
||||||
Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit
|
|
||||||
-
|
|
||||||
- builder1.put(resourcekey1, new ChunkStorage(path.resolve("region"), this.dataFixer, true));
|
- builder1.put(resourcekey1, new ChunkStorage(path.resolve("region"), this.dataFixer, true));
|
||||||
+ // Kaiiju start
|
+ // Kaiiju start
|
||||||
+ String worldName = this.levelStorage.getLevelId();
|
+ String worldName = this.levelStorage.getLevelId();
|
||||||
+ String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
+ dev.kaiijumc.kaiiju.region.RegionFileFormat 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;
|
+ 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));
|
+ builder1.put(resourcekey1, new ChunkStorage(formatName, linearCompression, path.resolve("region"), this.dataFixer, true));
|
||||||
+ // Kaiiju end
|
+ // Kaiiju end
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableMap<ResourceKey<LevelStem>, ChunkStorage> immutablemap1 = builder1.build(); // CraftBukkit
|
ImmutableMap<ResourceKey<Level>, ChunkStorage> immutablemap1 = builder1.build();
|
||||||
@@ -235,7 +239,7 @@ public class WorldUpgrader {
|
@@ -235,7 +240,7 @@ public class WorldUpgrader {
|
||||||
File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit
|
File file = this.levelStorage.getDimensionPath(world).toFile();
|
||||||
File file1 = new File(file, "region");
|
File file1 = new File(file, "region");
|
||||||
File[] afile = file1.listFiles((file2, s) -> {
|
File[] afile = file1.listFiles((file2, s) -> {
|
||||||
- return s.endsWith(".mca");
|
- return s.endsWith(".mca");
|
||||||
@@ -645,7 +704,7 @@ index e0bfeebeaac1aaea64bc07cdfdf7790e3e43ca7b..469802b9c454c5e98c0a55ba89559d9d
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (afile == null) {
|
if (afile == null) {
|
||||||
@@ -254,7 +258,11 @@ public class WorldUpgrader {
|
@@ -254,7 +259,11 @@ public class WorldUpgrader {
|
||||||
int l = Integer.parseInt(matcher.group(2)) << 5;
|
int l = Integer.parseInt(matcher.group(2)) << 5;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -659,7 +718,7 @@ index e0bfeebeaac1aaea64bc07cdfdf7790e3e43ca7b..469802b9c454c5e98c0a55ba89559d9d
|
|||||||
try {
|
try {
|
||||||
for (int i1 = 0; i1 < 32; ++i1) {
|
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
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||||
index 9c56304476b4fc841b5d7694232617586ebd8e84..f560aa13c6c8ffecb456f478687dc6a9eb5e8017 100644
|
index 5150d447c9dc2f539446749c8bee102050bab4ed..187ff795192c7eb56dffafa1ff6fa3068ac341c3 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
--- 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
|
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||||
@@ -59,8 +59,8 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
@@ -59,8 +59,8 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
||||||
@@ -668,23 +727,22 @@ index 9c56304476b4fc841b5d7694232617586ebd8e84..f560aa13c6c8ffecb456f478687dc6a9
|
|||||||
|
|
||||||
- public PoiManager(Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) {
|
- 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);
|
- 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
|
+ public PoiManager(dev.kaiijumc.kaiiju.region.RegionFileFormat 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
|
+ 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
|
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
|
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
|
index 8ebecb588058da174b0e0e19e54fcddfeeca1422..1d880f27dd147da683fc30ed6f1bfa43ecdb7d93 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||||
+++ b/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 {
|
@@ -37,11 +37,11 @@ public class ChunkStorage implements AutoCloseable {
|
||||||
public final RegionFileStorage regionFileCache;
|
public final RegionFileStorage regionFileCache;
|
||||||
// Paper end - async chunk loading
|
// Paper end - async chunk loading
|
||||||
|
|
||||||
- public ChunkStorage(Path directory, DataFixer dataFixer, boolean dsync) {
|
- public ChunkStorage(Path directory, DataFixer dataFixer, boolean dsync) {
|
||||||
+ public ChunkStorage(String format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
+ public ChunkStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
||||||
this.fixerUpper = dataFixer;
|
this.fixerUpper = dataFixer;
|
||||||
+
|
|
||||||
// Paper start - async chunk io
|
// Paper start - async chunk io
|
||||||
// remove IO worker
|
// remove IO worker
|
||||||
- this.regionFileCache = new RegionFileStorage(directory, dsync, true); // Paper - nuke IOWorker // Paper
|
- this.regionFileCache = new RegionFileStorage(directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||||
@@ -693,10 +751,10 @@ index 29facbdcbad17ce38bf785f7f3f8346d81cbc32f..52c2e0fe73a5af18535a2b0b9a506919
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
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
|
index 9248769e6d357f6eec68945fd7700e79b2942c41..024870a31469c40cd680be0399ce0e0e73839a0f 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||||
@@ -27,7 +27,7 @@ import net.minecraft.nbt.NbtIo;
|
@@ -26,7 +26,7 @@ import net.minecraft.nbt.NbtIo; // Paper
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@@ -705,8 +763,8 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788e
|
|||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static final int SECTOR_BYTES = 4096;
|
private static final int SECTOR_BYTES = 4096;
|
||||||
@@ -51,6 +51,16 @@ public class RegionFile implements AutoCloseable {
|
@@ -50,6 +50,16 @@ public class RegionFile implements AutoCloseable {
|
||||||
public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(true); // Paper
|
public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(); // Paper
|
||||||
public final Path regionFile; // Paper
|
public final Path regionFile; // Paper
|
||||||
|
|
||||||
+ // Kaiiju start - Abstract getters
|
+ // Kaiiju start - Abstract getters
|
||||||
@@ -722,7 +780,7 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788e
|
|||||||
// Paper start - try to recover from RegionFile header corruption
|
// Paper start - try to recover from RegionFile header corruption
|
||||||
private static long roundToSectors(long bytes) {
|
private static long roundToSectors(long bytes) {
|
||||||
long sectors = bytes >>> 12; // 4096 = 2^12
|
long sectors = bytes >>> 12; // 4096 = 2^12
|
||||||
@@ -129,7 +139,7 @@ public class RegionFile implements AutoCloseable {
|
@@ -128,7 +138,7 @@ public class RegionFile implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: only call for CHUNK regionfiles
|
// note: only call for CHUNK regionfiles
|
||||||
@@ -731,7 +789,7 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788e
|
|||||||
if (!this.canRecalcHeader) {
|
if (!this.canRecalcHeader) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -955,10 +965,10 @@ public class RegionFile implements AutoCloseable {
|
@@ -954,10 +964,10 @@ public class RegionFile implements AutoCloseable {
|
||||||
private static int getChunkIndex(int x, int z) {
|
private static int getChunkIndex(int x, int z) {
|
||||||
return (x & 31) + (z & 31) * 32;
|
return (x & 31) + (z & 31) * 32;
|
||||||
}
|
}
|
||||||
@@ -744,7 +802,7 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788e
|
|||||||
final int offset = getChunkIndex(x, z);
|
final int offset = getChunkIndex(x, z);
|
||||||
boolean previous = this.oversized[offset] == 1;
|
boolean previous = this.oversized[offset] == 1;
|
||||||
this.oversized[offset] = (byte) (oversized ? 1 : 0);
|
this.oversized[offset] = (byte) (oversized ? 1 : 0);
|
||||||
@@ -997,7 +1007,7 @@ public class RegionFile implements AutoCloseable {
|
@@ -996,7 +1006,7 @@ public class RegionFile implements AutoCloseable {
|
||||||
return this.regionFile.getParent().resolve(this.regionFile.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
|
return this.regionFile.getParent().resolve(this.regionFile.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,10 +812,10 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..d42c320179ae055b8675d1ce6ce1788e
|
|||||||
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
|
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
|
||||||
return NbtIo.read((java.io.DataInput) out);
|
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
|
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 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d01a6381c 100644
|
index db571f658f636cdda1dcdbaffa0c4da67fae11ad..21537b14c6c6789da3db04577f1c93998397678d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
@@ -22,9 +22,13 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -21,9 +21,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
|
|
||||||
public static final String ANVIL_EXTENSION = ".mca";
|
public static final String ANVIL_EXTENSION = ".mca";
|
||||||
private static final int MAX_CACHE_SIZE = 256;
|
private static final int MAX_CACHE_SIZE = 256;
|
||||||
@@ -766,24 +824,24 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
private final Path folder;
|
private final Path folder;
|
||||||
private final boolean sync;
|
private final boolean sync;
|
||||||
+ // Kaiiju start - Per world chunk format
|
+ // Kaiiju start - Per world chunk format
|
||||||
+ public final String format;
|
+ public final dev.kaiijumc.kaiiju.region.RegionFileFormat format;
|
||||||
+ public final int linearCompression;
|
+ public final int linearCompression;
|
||||||
+ // Kaiiju end
|
+ // Kaiiju end
|
||||||
|
|
||||||
private final boolean isChunkData; // Paper
|
private final boolean isChunkData; // Paper
|
||||||
|
|
||||||
@@ -57,11 +61,15 @@ public class RegionFileStorage implements AutoCloseable {
|
// Paper start - cache regionfile does not exist state
|
||||||
|
@@ -55,11 +59,15 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
// Paper end - cache regionfile does not exist state
|
// Paper end - cache regionfile does not exist state
|
||||||
|
|
||||||
- protected RegionFileStorage(Path directory, boolean dsync) { // Paper - protected constructor
|
- protected RegionFileStorage(Path directory, boolean dsync) { // Paper - protected constructor
|
||||||
+ protected RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Paper - protected constructor
|
+ protected RegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, boolean dsync) { // Paper - protected constructor
|
||||||
// Paper start - add isChunkData param
|
// Paper start - add isChunkData param
|
||||||
- this(directory, dsync, false);
|
- this(directory, dsync, false);
|
||||||
+ this(format, linearCompression, directory, dsync, false);
|
+ this(format, linearCompression, directory, dsync, false);
|
||||||
}
|
}
|
||||||
- RegionFileStorage(Path directory, boolean dsync, boolean isChunkData) {
|
- RegionFileStorage(Path directory, boolean dsync, boolean isChunkData) {
|
||||||
+ RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
+ RegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
||||||
+ // Kaiiju start
|
+ // Kaiiju start
|
||||||
+ this.format = format;
|
+ this.format = format;
|
||||||
+ this.linearCompression = linearCompression;
|
+ this.linearCompression = linearCompression;
|
||||||
@@ -791,19 +849,19 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
this.isChunkData = isChunkData;
|
this.isChunkData = isChunkData;
|
||||||
// Paper end - add isChunkData param
|
// Paper end - add isChunkData param
|
||||||
this.folder = directory;
|
this.folder = directory;
|
||||||
@@ -71,7 +79,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -70,7 +78,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
// Paper start
|
@Nullable
|
||||||
public static @Nullable ChunkPos getRegionFileCoordinates(Path file) {
|
public static ChunkPos getRegionFileCoordinates(Path file) {
|
||||||
String fileName = file.getFileName().toString();
|
String fileName = file.getFileName().toString();
|
||||||
- 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
|
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".mca") || !fileName.endsWith(".linear")) { // Kaiiju
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,29 +99,29 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -90,29 +98,29 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) {
|
- public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) {
|
||||||
+ public synchronized dev.kaiijumc.kaiiju.region.AbstractRegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { // Kaiiju
|
+ public synchronized dev.kaiijumc.kaiiju.region.AbstractRegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { // Kaiiju
|
||||||
return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()));
|
return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()));
|
||||||
@@ -836,7 +894,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
return regionfile;
|
return regionfile;
|
||||||
@@ -124,28 +132,46 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -123,28 +131,45 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
// Paper end - cache regionfile does not exist state
|
// Paper end - cache regionfile does not exist state
|
||||||
if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - configurable
|
if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - configurable
|
||||||
@@ -863,22 +921,21 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
+ this.markNonExisting(regionPos);
|
+ this.markNonExisting(regionPos);
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
} else {
|
} else {
|
||||||
|
+ // Kaiiju start - Polyglot
|
||||||
+ String extension = switch (this.format) {
|
+ String extension = switch (this.format) {
|
||||||
+ case "LINEAR" -> "linear";
|
+ case LINEAR -> "linear";
|
||||||
+ default -> "mca";
|
+ default -> "mca";
|
||||||
+ };
|
+ };
|
||||||
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension);
|
+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension);
|
||||||
|
+ // Kaiiju end
|
||||||
this.createRegionFile(regionPos);
|
this.createRegionFile(regionPos);
|
||||||
}
|
}
|
||||||
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatDebug)
|
|
||||||
+ org.bukkit.Bukkit.getLogger().info("Opening file " + path1 + " with format " + this.format + " (existingOnly = " + existingOnly + ")");
|
|
||||||
+
|
+
|
||||||
// Paper end - cache regionfile does not exist state
|
// Paper end - cache regionfile does not exist state
|
||||||
FileUtil.createDirectoriesSafe(this.folder); // Paper - only create directory if not existing only - moved from above
|
FileUtil.createDirectoriesSafe(this.folder); // Paper - only create directory if not existing only - moved from above
|
||||||
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
|
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
|
||||||
+ // Kaiiju end
|
|
||||||
+
|
|
||||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile1 = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(this.linearCompression, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Kaiiju
|
+ 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);
|
this.regionCache.putAndMoveToFirst(i, regionfile1);
|
||||||
@@ -890,7 +947,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
return regionfile1;
|
return regionfile1;
|
||||||
@@ -173,7 +199,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -172,7 +197,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -899,7 +956,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
synchronized (regionfile) {
|
synchronized (regionfile) {
|
||||||
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
|
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
|
||||||
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
|
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
|
||||||
@@ -220,14 +246,14 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -219,14 +244,14 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
@Nullable
|
@Nullable
|
||||||
public CompoundTag read(ChunkPos pos) throws IOException {
|
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
|
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||||
@@ -916,7 +973,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
// We add the regionfile parameter to avoid the potential deadlock (on fileLock) if we went back to obtain a regionfile
|
// 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
|
// if we decide to re-read
|
||||||
// Paper end
|
// Paper end
|
||||||
@@ -237,7 +263,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -236,7 +261,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
|
|
||||||
// Paper start
|
// Paper start
|
||||||
if (regionfile.isOversized(pos.x, pos.z)) {
|
if (regionfile.isOversized(pos.x, pos.z)) {
|
||||||
@@ -925,7 +982,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
return readOversizedChunk(regionfile, pos);
|
return readOversizedChunk(regionfile, pos);
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
@@ -251,12 +277,12 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -250,12 +275,12 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
if (this.isChunkData) {
|
if (this.isChunkData) {
|
||||||
ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound);
|
ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound);
|
||||||
if (!chunkPos.equals(pos)) {
|
if (!chunkPos.equals(pos)) {
|
||||||
@@ -941,7 +998,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,13 +316,13 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -289,13 +314,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
|
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
} finally { // Paper start
|
} finally { // Paper start
|
||||||
@@ -957,7 +1014,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
if (regionfile == null) {
|
if (regionfile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -326,7 +352,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -325,7 +350,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
|
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
|
||||||
@@ -966,7 +1023,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
if (nbt == null && regionfile == null) {
|
if (nbt == null && regionfile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -376,7 +402,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -375,7 +400,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
} finally { // Paper start
|
} finally { // Paper start
|
||||||
@@ -975,7 +1032,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
} // Paper end
|
} // Paper end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +411,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -384,7 +409,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||||
|
|
||||||
while (objectiterator.hasNext()) {
|
while (objectiterator.hasNext()) {
|
||||||
@@ -984,7 +1041,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
regionfile.close();
|
regionfile.close();
|
||||||
@@ -401,7 +427,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -400,7 +425,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||||
|
|
||||||
while (objectiterator.hasNext()) {
|
while (objectiterator.hasNext()) {
|
||||||
@@ -994,7 +1051,7 @@ index 9633b01d2d961fd1403e353484d336376ef009eb..c9fbba6f709ed0540dcc22b41e50ce9d
|
|||||||
regionfile.flush();
|
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
|
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
|
index 4aac1979cf57300825a999c876fcf24d3170e68e..3b96582f15d0985b670b5b5a1548800dee2154f4 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||||
+++ b/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
|
@@ -47,8 +47,8 @@ public class SectionStorage<R> extends RegionFileStorage implements AutoCloseabl
|
||||||
@@ -1003,16 +1060,16 @@ index 5561b8499a0503b850974b1dc309edfb80219549..414aa3ae00c2d28e754235e3e93b6b62
|
|||||||
|
|
||||||
- public SectionStorage(Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) {
|
- 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
|
- 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
|
+ public SectionStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat 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
|
+ super(format, linearCompression, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
|
||||||
this.codec = codecFactory;
|
this.codec = codecFactory;
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.fixerUpper = dataFixer;
|
this.fixerUpper = dataFixer;
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
index 2ead9af36c4d41c61b68a960ff17e25894efeb2a..cba3411386b7a9f596017d021d08f30c78f0c52b 100644
|
index b8f10ad8687f047f2b6705d47a91831e77d6b3b4..8882347b5b878c9c8cc1760941f2a153e967f780 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
@@ -554,7 +554,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
@@ -560,7 +560,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
Date: Thu, 16 Feb 2023 01:38:59 +0200
|
Date: Thu, 16 Feb 2023 01:38:59 +0200
|
||||||
Subject: [PATCH] Kaiiju Network Configuration
|
Subject: [PATCH] Network configuration
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index b86c90cc3601e666998cfa12f44515f605bb53eb..7c6d43d8a360530344ef296f4477750c8a298607 100644
|
index b7f43cce80742aa0cd523e930772ff84946f3eef..fa829cef4033625470dfae29ddf777e6c5ab8c55 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
@@ -198,4 +198,7 @@ public class KaiijuConfig {
|
@@ -203,4 +203,7 @@ public class KaiijuConfig {
|
||||||
private static void regionFormatSettings() {
|
else
|
||||||
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
linearFlushThreads = Math.max(linearFlushThreads, 1);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ private static void networkSettings() {
|
+ private static void networkSettings() {
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
Date: Thu, 16 Feb 2023 01:49:54 +0200
|
Date: Thu, 16 Feb 2023 01:49:54 +0200
|
||||||
Subject: [PATCH] Purpur Network SendNullEntityPackets
|
Subject: [PATCH] Send null entity packets
|
||||||
|
|
||||||
|
This is from Purpur. Don't send null entity packets.
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index 7c6d43d8a360530344ef296f4477750c8a298607..ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7 100644
|
index fa829cef4033625470dfae29ddf777e6c5ab8c55..47e23a196ae5e44600a64184b69141c00235baca 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
@@ -198,7 +198,10 @@ public class KaiijuConfig {
|
@@ -203,7 +203,10 @@ public class KaiijuConfig {
|
||||||
private static void regionFormatSettings() {
|
else
|
||||||
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
linearFlushThreads = Math.max(linearFlushThreads, 1);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ public static boolean sendNullEntityPackets = true;
|
+ public static boolean sendNullEntityPackets = true;
|
||||||
@@ -20,10 +21,10 @@ index 7c6d43d8a360530344ef296f4477750c8a298607..ab08e11f13921163b8ff1ff51ff9e9b8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||||
index b7fd8e70413c38923d0719aff803449e392383ac..fc778cf828c42065a7928d2f920fc1442aa4d503 100644
|
index 892a334d1b1c0784ed6838d1aa066403998b9a9f..eab1b19323f588030834b9a4cecd515c817f79d1 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||||
@@ -205,6 +205,11 @@ public class ServerEntity {
|
@@ -198,6 +198,11 @@ public class ServerEntity {
|
||||||
flag4 = true;
|
flag4 = true;
|
||||||
flag5 = true;
|
flag5 = true;
|
||||||
}
|
}
|
||||||
@@ -35,8 +36,8 @@ index b7fd8e70413c38923d0719aff803449e392383ac..fc778cf828c42065a7928d2f920fc144
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
||||||
@@ -279,6 +284,20 @@ public class ServerEntity {
|
@@ -270,6 +275,20 @@ public class ServerEntity {
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Kaiiju start - Don't send null move entity packets
|
+ // Kaiiju start - Don't send null move entity packets
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: kugge <sofiane.djerbi38@gmail.com>
|
||||||
Date: Sat, 8 Apr 2023 23:32:34 +0300
|
Date: Wed, 21 Jun 2023 17:26:24 +0200
|
||||||
Subject: [PATCH] Kaiiju Gameplay Configuration
|
Subject: [PATCH] Optimization Configuration
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index b42a3466f145a92608c8746fd4beb529b4a60b01..6d0e1edfb7d3c020f70f6a194f16e836b462c4de 100644
|
index 47e23a196ae5e44600a64184b69141c00235baca..90d97f3e0500a38e64ec0b88b2cab6ef28640c10 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
@@ -206,4 +206,7 @@ public class KaiijuConfig {
|
@@ -209,4 +209,7 @@ public class KaiijuConfig {
|
||||||
|
private static void networkSettings() {
|
||||||
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||||
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ private static void gameplaySettings() {
|
+ private static void optimizationSettings() {
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
index b194f4dbebcbbf5bb4e026a0169e2d24806b46ec..73d79fe0077b28db2f9e7fa13a1ae6eff9abd6a9 100644
|
index a6e7af5f4148e067660e9f5beeacde3a59a1de9c..6bd14857e0b0ef233f17f1a6e3e0fb313d59f641 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
@@ -143,4 +143,7 @@ public class KaiijuWorldConfig {
|
@@ -143,4 +143,7 @@ public class KaiijuWorldConfig {
|
||||||
@@ -25,7 +25,6 @@ index b194f4dbebcbbf5bb4e026a0169e2d24806b46ec..73d79fe0077b28db2f9e7fa13a1ae6ef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ private void gameplaySettings() {
|
+ private void optimizationSettings() {
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
\ No newline at end of file
|
|
||||||
30
patches/server/0008-Gameplay-Configuration.patch
Normal file
30
patches/server/0008-Gameplay-Configuration.patch
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sat, 8 Apr 2023 23:32:34 +0300
|
||||||
|
Subject: [PATCH] Gameplay Configuration
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index 90d97f3e0500a38e64ec0b88b2cab6ef28640c10..859c2ac4e46b840f9552d1ccbf9409c9666e84de 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -212,4 +212,7 @@ public class KaiijuConfig {
|
||||||
|
|
||||||
|
private static void optimizationSettings() {
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ private static void gameplaySettings() {
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 6bd14857e0b0ef233f17f1a6e3e0fb313d59f641..05f9c01131e78927d88f1170c3eda4adf25ac8ba 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -146,4 +146,7 @@ public class KaiijuWorldConfig {
|
||||||
|
|
||||||
|
private void optimizationSettings() {
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ private void gameplaySettings() {
|
||||||
|
+ }
|
||||||
|
}
|
||||||
@@ -1,26 +1,28 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Xymb <xymb@endcrystal.me>
|
From: Xymb <xymb@endcrystal.me>
|
||||||
Date: Sat, 8 Apr 2023 23:38:13 +0300
|
Date: Sat, 8 Apr 2023 23:38:13 +0300
|
||||||
Subject: [PATCH] Kaiiju Gameplay ShulkerDropContentsWhenDestroyed
|
Subject: [PATCH] Shulker drop contents when destroyed
|
||||||
|
|
||||||
|
Don't drop shulker contents when shulker items are destroyed (by cactus,
|
||||||
|
lava..)
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
index 73d79fe0077b28db2f9e7fa13a1ae6eff9abd6a9..bac11b0e30a86d0689693ff129b53bcad7c2034c 100644
|
index 05f9c01131e78927d88f1170c3eda4adf25ac8ba..55dcbb48450b24f80e0a04bedeb54f64e94ebb9e 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
@@ -144,6 +144,9 @@ public class KaiijuWorldConfig {
|
@@ -144,7 +144,10 @@ public class KaiijuWorldConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
+ public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||||
+
|
+
|
||||||
private void gameplaySettings() {
|
private void optimizationSettings() {
|
||||||
+ shulkerBoxDropContentsWhenDestroyed = getBoolean("gameplay.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
+ shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
\ No newline at end of file
|
private void gameplaySettings() {
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||||
index b0204af850ee182773ad458208cccd946ad148d5..cb67928eb9d493b4c43489aa06a5c0c947999dac 100644
|
index e483186a5292b3b53bfb1af4d56f55fcc1a6106c..a178bb3a1810c39c0131ccedb926d61b761a4b0e 100644
|
||||||
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
|
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/BlockItem.java
|
+++ b/src/main/java/net/minecraft/world/item/BlockItem.java
|
||||||
@@ -288,7 +288,7 @@ public class BlockItem extends Item {
|
@@ -288,7 +288,7 @@ public class BlockItem extends Item {
|
||||||
@@ -28,7 +30,7 @@ index b0204af850ee182773ad458208cccd946ad148d5..cb67928eb9d493b4c43489aa06a5c0c9
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroyed(ItemEntity entity) {
|
public void onDestroyed(ItemEntity entity) {
|
||||||
- if (this.block instanceof ShulkerBoxBlock) {
|
- if (this.block instanceof ShulkerBoxBlock) {
|
||||||
+ if (this.block instanceof ShulkerBoxBlock && entity.getLevel().kaiijuConfig.shulkerBoxDropContentsWhenDestroyed) { // Kaiiju
|
+ if (this.block instanceof ShulkerBoxBlock && entity.level().kaiijuConfig.shulkerBoxDropContentsWhenDestroyed) { // Kaiiju
|
||||||
ItemStack itemstack = entity.getItem();
|
ItemStack itemstack = entity.getItem();
|
||||||
CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
|
CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
|
||||||
|
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
Date: Sun, 9 Apr 2023 17:06:46 +0300
|
Date: Sun, 9 Apr 2023 17:06:46 +0300
|
||||||
Subject: [PATCH] Purpur Gameplay ServerModName
|
Subject: [PATCH] Server mod name
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index 6d0e1edfb7d3c020f70f6a194f16e836b462c4de..9fb33b35b4d6842ca8597f77a4116e3983ebfbcb 100644
|
index 859c2ac4e46b840f9552d1ccbf9409c9666e84de..2aa40f154c48ee7558b0efdc3bf26e205bb9f799 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
@@ -207,6 +207,9 @@ public class KaiijuConfig {
|
@@ -213,6 +213,9 @@ public class KaiijuConfig {
|
||||||
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
private static void optimizationSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
+ public static String serverModName = "Kaiiju";
|
+ public static String serverModName = "Kaiiju";
|
||||||
@@ -19,7 +19,7 @@ index 6d0e1edfb7d3c020f70f6a194f16e836b462c4de..9fb33b35b4d6842ca8597f77a4116e39
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
index a7233bcc99e9bf148348ebb36bbb15b2eadb381f..865b022bb52d8d7b12355a01f3216a4ee8d4c045 100644
|
index ef9a17e9b9cd2866374aa22c5ec7c5b46b06e341..211868046f442f316f419734c03b2fa535bad196 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -1833,7 +1833,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1833,7 +1833,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Xymb <xymb@endcrystal.me>
|
From: Xymb <xymb@endcrystal.me>
|
||||||
Date: Fri, 14 Apr 2023 02:12:58 +0200
|
Date: Fri, 14 Apr 2023 02:12:58 +0200
|
||||||
Subject: [PATCH] Kaiiju Linear CrashOnBrokenSymlink
|
Subject: [PATCH] Crash on broken symlink
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
index bac11b0e30a86d0689693ff129b53bcad7c2034c..0f0cfd958f7d2c6d2ca4192be1b986900a2bfa53 100644
|
index 55dcbb48450b24f80e0a04bedeb54f64e94ebb9e..f3f824d0ab1a2a72825c40b67192386479a0b34c 100644
|
||||||
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
@@ -127,6 +127,7 @@ public class KaiijuWorldConfig {
|
@@ -127,6 +127,7 @@ public class KaiijuWorldConfig {
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
|
public RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
||||||
public String regionFormatName = "ANVIL";
|
|
||||||
+ public boolean linearCrashOnBrokenSymlink = true;
|
+ public boolean linearCrashOnBrokenSymlink = true;
|
||||||
public int regionFormatLinearCompressionLevel = 1;
|
public int regionFormatLinearCompressionLevel = 1;
|
||||||
|
|
||||||
@@ -25,12 +25,12 @@ index bac11b0e30a86d0689693ff129b53bcad7c2034c..0f0cfd958f7d2c6d2ca4192be1b98690
|
|||||||
|
|
||||||
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||||
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||||
index a62a1b281bd0b6ad7d59b45b9470d84f496f6539..7f87dfa131ab7d40a94cf6355765478f2961342e 100644
|
index abf5e2a06af9853b58ac9107cd6e9787c4185c66..389c68c0becd2f69dc1004d0b383f1a8784214c0 100644
|
||||||
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||||
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||||
@@ -86,10 +86,11 @@ public class ThreadedWorldUpgrader {
|
@@ -87,10 +87,11 @@ public class ThreadedWorldUpgrader {
|
||||||
// Kaiiju start
|
// Kaiiju start
|
||||||
String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
dev.kaiijumc.kaiiju.region.RegionFileFormat 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;
|
int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatLinearCompressionLevel;
|
||||||
+ boolean linearCrashOnBrokenSymlink = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.linearCrashOnBrokenSymlink;
|
+ boolean linearCrashOnBrokenSymlink = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.linearCrashOnBrokenSymlink;
|
||||||
LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
|
LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
|
||||||
@@ -42,11 +42,11 @@ index a62a1b281bd0b6ad7d59b45b9470d84f496f6539..7f87dfa131ab7d40a94cf6355765478f
|
|||||||
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
index 43503974433c4d1808b2acb2b79f46d640725dc0..73ac94eaebdeaa94c83f1f23b53e686d867e6f98 100644
|
index 90991db650d2f0e9a3f7b00bb5b7586ade003bb0..c0ee91a1f333434a2529429d670b62a83aeeb7b2 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
@@ -272,7 +272,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -210,7 +210,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
// Paper end
|
// Paper end - optimise chunk tick iteration
|
||||||
|
|
||||||
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) {
|
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
||||||
- super(world.getLevel().kaiijuConfig.regionFormatName, world.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
|
- super(world.getLevel().kaiijuConfig.regionFormatName, world.getLevel().kaiijuConfig.regionFormatLinearCompressionLevel, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
|
||||||
@@ -54,31 +54,31 @@ index 43503974433c4d1808b2acb2b79f46d640725dc0..73ac94eaebdeaa94c83f1f23b53e686d
|
|||||||
// Paper - rewrite chunk system
|
// Paper - rewrite chunk system
|
||||||
this.tickingGenerated = new AtomicInteger();
|
this.tickingGenerated = new AtomicInteger();
|
||||||
//this.playerMap = new PlayerMap(); // Folia - region threading
|
//this.playerMap = new PlayerMap(); // Folia - region threading
|
||||||
@@ -317,7 +317,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -255,7 +255,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.lightEngine = new ThreadedLevelLightEngine(chunkProvider, this, this.level.dimensionType().hasSkyLight(), null, null); // Paper - rewrite chunk system
|
||||||
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
||||||
this.overworldDataStorage = persistentStateManagerFactory;
|
this.overworldDataStorage = persistentStateManagerFactory;
|
||||||
- this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
- this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||||
+ this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, this.level.kaiijuConfig.linearCrashOnBrokenSymlink, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
+ this.poiManager = new PoiManager(this.level.kaiijuConfig.regionFormatName, this.level.kaiijuConfig.regionFormatLinearCompressionLevel, this.level.kaiijuConfig.linearCrashOnBrokenSymlink, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||||
this.setViewDistance(viewDistance);
|
this.setServerViewDistance(viewDistance);
|
||||||
// Paper start
|
// Paper start
|
||||||
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
index 20359c63b19c7e0c703ef1562fb774803d631c41..35ae624be25b66d5615dc19cbe7eb8785c7029b5 100644
|
index eb7a06f4d0e87d8cba86c7eccf2c1fa02ad503d2..95e4ea89dbffb72322506e5e6c79e3605e2f9593 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -425,8 +425,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -451,8 +451,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 {
|
private static final class EntityRegionFileStorage extends net.minecraft.world.level.chunk.storage.RegionFileStorage {
|
||||||
- public EntityRegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
|
||||||
|
- public EntityRegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
||||||
- super(format, linearCompression, directory, dsync); // Kaiiju
|
- super(format, linearCompression, directory, dsync); // Kaiiju
|
||||||
+ public EntityRegionFileStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync) { // Kaiiju
|
+ public EntityRegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync) { // Kaiiju
|
||||||
+ super(format, linearCompression, linearCrashOnBrokenSymlink, directory, dsync); // Kaiiju
|
+ super(format, linearCompression, linearCrashOnBrokenSymlink, directory, dsync); // Kaiiju
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
|
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
|
||||||
@@ -632,7 +632,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -808,7 +808,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||||
@@ -88,12 +88,12 @@ index 20359c63b19c7e0c703ef1562fb774803d631c41..35ae624be25b66d5615dc19cbe7eb878
|
|||||||
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
|
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
|
||||||
StructureTemplateManager structuretemplatemanager = minecraftserver.getStructureManager();
|
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
|
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||||
index 469802b9c454c5e98c0a55ba89559d9d8ba0c4c0..1652398c211c4366dde1d973bdb8e9d2c5c67ff4 100644
|
index 3b02b7905fd16be28ba986302c1f99dfb5eb2ab8..d7838a09a7d5a9a3401b1a90bc893f0ac886a70f 100644
|
||||||
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||||
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||||
@@ -119,7 +119,8 @@ public class WorldUpgrader {
|
@@ -120,7 +120,8 @@ public class WorldUpgrader {
|
||||||
String worldName = this.levelStorage.getLevelId();
|
String worldName = this.levelStorage.getLevelId();
|
||||||
String formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.regionFormatName;
|
dev.kaiijumc.kaiiju.region.RegionFileFormat 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;
|
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));
|
- builder1.put(resourcekey1, new ChunkStorage(formatName, linearCompression, path.resolve("region"), this.dataFixer, true));
|
||||||
+ boolean linearCrashOnBrokenSymlink = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.linearCrashOnBrokenSymlink;
|
+ boolean linearCrashOnBrokenSymlink = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().kaiijuConfig.linearCrashOnBrokenSymlink;
|
||||||
@@ -102,32 +102,31 @@ index 469802b9c454c5e98c0a55ba89559d9d8ba0c4c0..1652398c211c4366dde1d973bdb8e9d2
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||||
index f560aa13c6c8ffecb456f478687dc6a9eb5e8017..f0354203f974a8d7440407a5561ffa0fcb63182d 100644
|
index 187ff795192c7eb56dffafa1ff6fa3068ac341c3..b9cf3b9f2cdb554d267c6dc3436e011c7e607228 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
--- 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
|
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||||
@@ -59,8 +59,8 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
@@ -59,8 +59,8 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
||||||
// Paper end - rewrite chunk system
|
// Paper end - rewrite chunk system
|
||||||
|
|
||||||
|
|
||||||
- public PoiManager(String formatName, int linearCompression, Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) { // Kaiiju
|
- public PoiManager(dev.kaiijumc.kaiiju.region.RegionFileFormat 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
|
- super(formatName, linearCompression, path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world); // Kaiiju
|
||||||
+ public PoiManager(String formatName, int linearCompression, boolean linearCrashOnBrokenSymlink, Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) { // Kaiiju
|
+ public PoiManager(dev.kaiijumc.kaiiju.region.RegionFileFormat formatName, int linearCompression, boolean linearCrashOnBrokenSymlink, Path path, DataFixer dataFixer, boolean dsync, RegistryAccess registryManager, LevelHeightAccessor world) { // Kaiiju
|
||||||
+ super(formatName, linearCompression, linearCrashOnBrokenSymlink, path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world); // Kaiiju
|
+ super(formatName, linearCompression, linearCrashOnBrokenSymlink, path, PoiSection::codec, PoiSection::new, dataFixer, DataFixTypes.POI_CHUNK, dsync, registryManager, world); // Kaiiju
|
||||||
this.world = (net.minecraft.server.level.ServerLevel)world; // Paper - rewrite chunk system
|
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
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||||
index 52c2e0fe73a5af18535a2b0b9a506919e3f93003..ea54af3f68c6534ff5a71ca0b7a99d126557868e 100644
|
index 1d880f27dd147da683fc30ed6f1bfa43ecdb7d93..41598adf6d49a44bcaadfff3797221460a6d93ba 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||||
@@ -37,12 +37,12 @@ public class ChunkStorage implements AutoCloseable {
|
@@ -37,11 +37,11 @@ public class ChunkStorage implements AutoCloseable {
|
||||||
public final RegionFileStorage regionFileCache;
|
public final RegionFileStorage regionFileCache;
|
||||||
// Paper end - async chunk loading
|
// Paper end - async chunk loading
|
||||||
|
|
||||||
- public ChunkStorage(String format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
- public ChunkStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
||||||
+ public ChunkStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
+ public ChunkStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
||||||
this.fixerUpper = dataFixer;
|
this.fixerUpper = dataFixer;
|
||||||
|
|
||||||
// Paper start - async chunk io
|
// Paper start - async chunk io
|
||||||
// remove IO worker
|
// remove IO worker
|
||||||
- this.regionFileCache = new RegionFileStorage(format, linearCompression, directory, dsync, true); // Paper - nuke IOWorker // Paper
|
- this.regionFileCache = new RegionFileStorage(format, linearCompression, directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||||
@@ -136,10 +135,10 @@ index 52c2e0fe73a5af18535a2b0b9a506919e3f93003..ea54af3f68c6534ff5a71ca0b7a99d12
|
|||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
index c9fbba6f709ed0540dcc22b41e50ce9d01a6381c..70e3ee306283263cdcdb7a66c80fc23484385aac 100644
|
index 21537b14c6c6789da3db04577f1c93998397678d..93d0a6f635544b3a86111e1854a27cfdd8aee7b4 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
@@ -20,6 +20,7 @@ import net.minecraft.world.level.ChunkPos;
|
@@ -19,6 +19,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||||
|
|
||||||
public class RegionFileStorage implements AutoCloseable {
|
public class RegionFileStorage implements AutoCloseable {
|
||||||
|
|
||||||
@@ -147,26 +146,26 @@ index c9fbba6f709ed0540dcc22b41e50ce9d01a6381c..70e3ee306283263cdcdb7a66c80fc234
|
|||||||
public static final String ANVIL_EXTENSION = ".mca";
|
public static final String ANVIL_EXTENSION = ".mca";
|
||||||
private static final int MAX_CACHE_SIZE = 256;
|
private static final int MAX_CACHE_SIZE = 256;
|
||||||
public final Long2ObjectLinkedOpenHashMap<dev.kaiijumc.kaiiju.region.AbstractRegionFile> regionCache = new Long2ObjectLinkedOpenHashMap(); // Kaiiju
|
public final Long2ObjectLinkedOpenHashMap<dev.kaiijumc.kaiiju.region.AbstractRegionFile> regionCache = new Long2ObjectLinkedOpenHashMap(); // Kaiiju
|
||||||
@@ -28,6 +29,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -27,6 +28,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
// Kaiiju start - Per world chunk format
|
// Kaiiju start - Per world chunk format
|
||||||
public final String format;
|
public final dev.kaiijumc.kaiiju.region.RegionFileFormat format;
|
||||||
public final int linearCompression;
|
public final int linearCompression;
|
||||||
+ public final boolean linearCrashOnBrokenSymlink;
|
+ public final boolean linearCrashOnBrokenSymlink;
|
||||||
// Kaiiju end
|
// Kaiiju end
|
||||||
|
|
||||||
private final boolean isChunkData; // Paper
|
private final boolean isChunkData; // Paper
|
||||||
@@ -61,14 +63,15 @@ public class RegionFileStorage implements AutoCloseable {
|
|
||||||
|
@@ -59,14 +61,15 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
// Paper end - cache regionfile does not exist state
|
// Paper end - cache regionfile does not exist state
|
||||||
|
|
||||||
- protected RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Paper - protected constructor
|
- protected RegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, boolean dsync) { // Paper - protected constructor
|
||||||
+ protected RegionFileStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync) { // Paper - protected constructor
|
+ protected RegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync) { // Paper - protected constructor
|
||||||
// Paper start - add isChunkData param
|
// Paper start - add isChunkData param
|
||||||
- this(format, linearCompression, directory, dsync, false);
|
- this(format, linearCompression, directory, dsync, false);
|
||||||
+ this(format, linearCompression, linearCrashOnBrokenSymlink, directory, dsync, false);
|
+ this(format, linearCompression, linearCrashOnBrokenSymlink, directory, dsync, false);
|
||||||
}
|
}
|
||||||
- RegionFileStorage(String format, int linearCompression, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
- RegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
||||||
+ RegionFileStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
+ RegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path directory, boolean dsync, boolean isChunkData) { // Kaiiju
|
||||||
// Kaiiju start
|
// Kaiiju start
|
||||||
this.format = format;
|
this.format = format;
|
||||||
this.linearCompression = linearCompression;
|
this.linearCompression = linearCompression;
|
||||||
@@ -174,7 +173,7 @@ index c9fbba6f709ed0540dcc22b41e50ce9d01a6381c..70e3ee306283263cdcdb7a66c80fc234
|
|||||||
// Kaiiju end
|
// Kaiiju end
|
||||||
this.isChunkData = isChunkData;
|
this.isChunkData = isChunkData;
|
||||||
// Paper end - add isChunkData param
|
// Paper end - add isChunkData param
|
||||||
@@ -109,6 +112,20 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -108,6 +111,20 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
return regionfile != null ? regionfile.hasChunk(pos) : false;
|
return regionfile != null ? regionfile.hasChunk(pos) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +194,7 @@ index c9fbba6f709ed0540dcc22b41e50ce9d01a6381c..70e3ee306283263cdcdb7a66c80fc234
|
|||||||
public synchronized dev.kaiijumc.kaiiju.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Kaiiju
|
public synchronized dev.kaiijumc.kaiiju.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Kaiiju
|
||||||
return this.getRegionFile(chunkcoordintpair, existingOnly, false);
|
return this.getRegionFile(chunkcoordintpair, existingOnly, false);
|
||||||
}
|
}
|
||||||
@@ -144,6 +161,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -143,6 +160,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
if (existingOnly) {
|
if (existingOnly) {
|
||||||
Path anvil = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
Path anvil = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||||
Path linear = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
|
Path linear = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear");
|
||||||
@@ -203,25 +202,25 @@ index c9fbba6f709ed0540dcc22b41e50ce9d01a6381c..70e3ee306283263cdcdb7a66c80fc234
|
|||||||
if (java.nio.file.Files.exists(anvil)) path1 = anvil;
|
if (java.nio.file.Files.exists(anvil)) path1 = anvil;
|
||||||
else if (java.nio.file.Files.exists(linear)) path1 = linear;
|
else if (java.nio.file.Files.exists(linear)) path1 = linear;
|
||||||
else {
|
else {
|
||||||
@@ -156,6 +174,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -158,6 +176,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
default -> "mca";
|
|
||||||
};
|
};
|
||||||
path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension);
|
path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension);
|
||||||
+ guardAgainstBrokenSymlinks(path1);
|
// Kaiiju end
|
||||||
|
+ guardAgainstBrokenSymlinks(path1); // Kaiiju - Crash on broken symlink
|
||||||
this.createRegionFile(regionPos);
|
this.createRegionFile(regionPos);
|
||||||
}
|
}
|
||||||
if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatDebug)
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||||
index 414aa3ae00c2d28e754235e3e93b6b623d4fd180..15e376fac063430e4355c6ffcd25c35a8ce20c5b 100644
|
index 3b96582f15d0985b670b5b5a1548800dee2154f4..e8f1be83ff75045d4d57a43f1899efee7bd47183 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java
|
||||||
+++ b/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
|
@@ -47,8 +47,8 @@ public class SectionStorage<R> extends RegionFileStorage implements AutoCloseabl
|
||||||
public final RegistryAccess registryAccess; // Paper - rewrite chunk system
|
public final RegistryAccess registryAccess; // Paper - rewrite chunk system
|
||||||
protected final LevelHeightAccessor levelHeightAccessor;
|
protected final LevelHeightAccessor levelHeightAccessor;
|
||||||
|
|
||||||
- public SectionStorage(String format, int linearCompression, Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) { // Kaiiju
|
- public SectionStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat 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
|
- super(format, linearCompression, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
|
||||||
+ public SectionStorage(String format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) { // Kaiiju
|
+ public SectionStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, boolean linearCrashOnBrokenSymlink, Path path, Function<Runnable, Codec<R>> codecFactory, Function<Runnable, R> factory, DataFixer dataFixer, DataFixTypes dataFixTypes, boolean dsync, RegistryAccess dynamicRegistryManager, LevelHeightAccessor world) { // Kaiiju
|
||||||
+ super(format, linearCompression, linearCrashOnBrokenSymlink, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
|
+ super(format, linearCompression, linearCrashOnBrokenSymlink, path, dsync); // Paper - remove mojang I/O thread // Kaiiju
|
||||||
this.codec = codecFactory;
|
this.codec = codecFactory;
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
36
patches/server/0012-Toggle-void-trading.patch
Normal file
36
patches/server/0012-Toggle-void-trading.patch
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 23 Apr 2023 15:34:30 +0300
|
||||||
|
Subject: [PATCH] Toggle void trading
|
||||||
|
|
||||||
|
Don't close trading windows when the villager is unloaded.
|
||||||
|
You should set chunk-unloads to 0s in paper config file to enable void
|
||||||
|
trading. Or use Kaiivoid plugin.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index f3f824d0ab1a2a72825c40b67192386479a0b34c..95ed6cb7b94797187d1011cab344e187b39d9193 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -152,6 +152,9 @@ public class KaiijuWorldConfig {
|
||||||
|
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public boolean fixVoidTrading = true;
|
||||||
|
+
|
||||||
|
private void gameplaySettings() {
|
||||||
|
+ fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
index 383e500ec098d671442f81bba6742ee44ca64450..3950b404482b0c6244141301e6ee3b4013327b2b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -3016,7 +3016,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
// Spigot Start
|
||||||
|
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
||||||
|
// Paper start
|
||||||
|
- if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
|
||||||
|
+ if (entity.level().kaiijuConfig.fixVoidTrading && entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) { // Kaiiju
|
||||||
|
merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED);
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
219
patches/server/0013-Toggle-optimize-hoppers.patch
Normal file
219
patches/server/0013-Toggle-optimize-hoppers.patch
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Thu, 27 Apr 2023 03:49:08 +0300
|
||||||
|
Subject: [PATCH] Toggle optimize hoppers
|
||||||
|
|
||||||
|
Paper optimize hoppers patch break a lot of technical redstone farms because of piston updates. (Example: twiti888 wood farm)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 95ed6cb7b94797187d1011cab344e187b39d9193..6d7356cc07da58b1cef8d8963e790251d765de2c 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -147,9 +147,11 @@ public class KaiijuWorldConfig {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||||
|
+ public boolean optimizeHoppers = true;
|
||||||
|
|
||||||
|
private void optimizationSettings() {
|
||||||
|
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
|
+ optimizeHoppers = getBoolean("optimization.optimize-hoppers", optimizeHoppers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
index 97858b410769f95e4a8d8acd757216ffe06f8cf4..036683a0ea4df0fe2bd7aca434471d3de0c07710 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
|
@@ -441,49 +441,51 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
if (HopperBlockEntity.isFullContainer(iinventory1, enumdirection)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
+ // Kaiiju start - Toggle paper broken redstone
|
||||||
|
// Paper start - replace logic; MAKE SURE TO CHECK FOR DIFFS ON UPDATES
|
||||||
|
- return hopperPush(world, iinventory1, enumdirection, hopper);
|
||||||
|
- // for (int i = 0; i < iinventory.getContainerSize(); ++i) {
|
||||||
|
- // if (!iinventory.getItem(i).isEmpty()) {
|
||||||
|
- // ItemStack itemstack = iinventory.getItem(i).copy();
|
||||||
|
- // // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
|
||||||
|
-
|
||||||
|
- // // CraftBukkit start - Call event when pushing items into other inventories
|
||||||
|
- // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
|
||||||
|
-
|
||||||
|
- // Inventory destinationInventory;
|
||||||
|
- // // Have to special case large chests as they work oddly
|
||||||
|
- // if (iinventory1 instanceof CompoundContainer) {
|
||||||
|
- // destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory1);
|
||||||
|
- // } else if (iinventory1.getOwner() != null) {
|
||||||
|
- // destinationInventory = iinventory1.getOwner().getInventory();
|
||||||
|
- // } else {
|
||||||
|
- // destinationInventory = new CraftInventory(iinventory);
|
||||||
|
- // }
|
||||||
|
-
|
||||||
|
- // InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
|
||||||
|
- // world.getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
- // if (event.isCancelled()) {
|
||||||
|
- // hopper.setItem(i, itemstack);
|
||||||
|
- // hopper.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||||
|
- // return false;
|
||||||
|
- // }
|
||||||
|
- // int origCount = event.getItem().getAmount(); // Spigot
|
||||||
|
- // ItemStack itemstack1 = HopperBlockEntity.addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
|
||||||
|
+ if (world.kaiijuConfig.optimizeHoppers) return hopperPush(world, iinventory1, enumdirection, hopper);
|
||||||
|
+ for (int i = 0; i < iinventory.getContainerSize(); ++i) {
|
||||||
|
+ if (!iinventory.getItem(i).isEmpty()) {
|
||||||
|
+ ItemStack itemstack = iinventory.getItem(i).copy();
|
||||||
|
+ // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
|
||||||
|
+
|
||||||
|
+ // CraftBukkit start - Call event when pushing items into other inventories
|
||||||
|
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
|
||||||
|
+
|
||||||
|
+ Inventory destinationInventory;
|
||||||
|
+ // Have to special case large chests as they work oddly
|
||||||
|
+ if (iinventory1 instanceof CompoundContainer) {
|
||||||
|
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory1);
|
||||||
|
+ } else if (iinventory1.getOwner() != null) {
|
||||||
|
+ destinationInventory = iinventory1.getOwner().getInventory();
|
||||||
|
+ } else {
|
||||||
|
+ destinationInventory = new CraftInventory(iinventory);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
|
||||||
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ hopper.setItem(i, itemstack);
|
||||||
|
+ hopper.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ int origCount = event.getItem().getAmount(); // Spigot
|
||||||
|
+ ItemStack itemstack1 = HopperBlockEntity.addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
- // if (itemstack1.isEmpty()) {
|
||||||
|
- // iinventory1.setChanged();
|
||||||
|
- // return true;
|
||||||
|
- // }
|
||||||
|
+ if (itemstack1.isEmpty()) {
|
||||||
|
+ iinventory1.setChanged();
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- // itemstack.shrink(origCount - itemstack1.getCount()); // Spigot
|
||||||
|
- // iinventory.setItem(i, itemstack);
|
||||||
|
- // }
|
||||||
|
- // }
|
||||||
|
+ itemstack.shrink(origCount - itemstack1.getCount()); // Spigot
|
||||||
|
+ iinventory.setItem(i, itemstack);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- // return false;
|
||||||
|
+ return false;
|
||||||
|
// Paper end
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -525,6 +527,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
if (iinventory != null) {
|
||||||
|
Direction enumdirection = Direction.DOWN;
|
||||||
|
|
||||||
|
+ // Kaiiju start - toggle paper broken redstone
|
||||||
|
+ if (!world.kaiijuConfig.optimizeHoppers)
|
||||||
|
+ return HopperBlockEntity.isEmptyContainer(iinventory, enumdirection) ? false : HopperBlockEntity.getSlots(iinventory, enumdirection).anyMatch((i) -> {
|
||||||
|
+ return HopperBlockEntity.a(hopper, iinventory, i, enumdirection, world); // Spigot
|
||||||
|
+ });
|
||||||
|
+ // Kaiiju end
|
||||||
|
// Paper start - optimize hoppers and remove streams
|
||||||
|
worldData.skipPullModeEventFire = worldData.skipHopperEvents; // Folia - region threading
|
||||||
|
// merge container isEmpty check and move logic into one loop
|
||||||
|
@@ -573,48 +581,50 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
private static boolean a(Hopper ihopper, Container iinventory, int i, Direction enumdirection, Level world) { // Spigot
|
||||||
|
ItemStack itemstack = iinventory.getItem(i);
|
||||||
|
|
||||||
|
+ // Kaiiju start - toggle paper broken redstone
|
||||||
|
// Paper start - replace pull logic; MAKE SURE TO CHECK FOR DIFFS WHEN UPDATING
|
||||||
|
if (!itemstack.isEmpty() && HopperBlockEntity.canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { // If this logic changes, update above. this is left unused incase reflective plugins
|
||||||
|
- return hopperPull(world, ihopper, iinventory, itemstack, i);
|
||||||
|
- // ItemStack itemstack1 = itemstack.copy();
|
||||||
|
- // // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
|
||||||
|
- // // CraftBukkit start - Call event on collection of items from inventories into the hopper
|
||||||
|
- // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
|
||||||
|
-
|
||||||
|
- // Inventory sourceInventory;
|
||||||
|
- // // Have to special case large chests as they work oddly
|
||||||
|
- // if (iinventory instanceof CompoundContainer) {
|
||||||
|
- // sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory);
|
||||||
|
- // } else if (iinventory.getOwner() != null) {
|
||||||
|
- // sourceInventory = iinventory.getOwner().getInventory();
|
||||||
|
- // } else {
|
||||||
|
- // sourceInventory = new CraftInventory(iinventory);
|
||||||
|
- // }
|
||||||
|
-
|
||||||
|
- // InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
|
||||||
|
-
|
||||||
|
- // Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
- // if (event.isCancelled()) {
|
||||||
|
- // iinventory.setItem(i, itemstack1);
|
||||||
|
-
|
||||||
|
- // if (ihopper instanceof HopperBlockEntity) {
|
||||||
|
- // ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||||
|
- // }
|
||||||
|
-
|
||||||
|
- // return false;
|
||||||
|
- // }
|
||||||
|
- // int origCount = event.getItem().getAmount(); // Spigot
|
||||||
|
- // ItemStack itemstack2 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
|
||||||
|
- // // CraftBukkit end
|
||||||
|
-
|
||||||
|
- // if (itemstack2.isEmpty()) {
|
||||||
|
- // iinventory.setChanged();
|
||||||
|
- // return true;
|
||||||
|
- // }
|
||||||
|
-
|
||||||
|
- // itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot
|
||||||
|
- // iinventory.setItem(i, itemstack1);
|
||||||
|
+ if (world.kaiijuConfig.optimizeHoppers) return hopperPull(world, ihopper, iinventory, itemstack, i);
|
||||||
|
+ ItemStack itemstack1 = itemstack.copy();
|
||||||
|
+ // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
|
||||||
|
+ // CraftBukkit start - Call event on collection of items from inventories into the hopper
|
||||||
|
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
|
||||||
|
+
|
||||||
|
+ Inventory sourceInventory;
|
||||||
|
+ // Have to special case large chests as they work oddly
|
||||||
|
+ if (iinventory instanceof CompoundContainer) {
|
||||||
|
+ sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) iinventory);
|
||||||
|
+ } else if (iinventory.getOwner() != null) {
|
||||||
|
+ sourceInventory = iinventory.getOwner().getInventory();
|
||||||
|
+ } else {
|
||||||
|
+ sourceInventory = new CraftInventory(iinventory);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
|
||||||
|
+
|
||||||
|
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ iinventory.setItem(i, itemstack1);
|
||||||
|
+
|
||||||
|
+ if (ihopper instanceof HopperBlockEntity) {
|
||||||
|
+ ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ int origCount = event.getItem().getAmount(); // Spigot
|
||||||
|
+ ItemStack itemstack2 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
|
||||||
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
|
+ if (itemstack2.isEmpty()) {
|
||||||
|
+ iinventory.setChanged();
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot
|
||||||
|
+ iinventory.setItem(i, itemstack1);
|
||||||
|
// Paper end
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
36
patches/server/0014-Toggle-tick-level-when-empty.patch
Normal file
36
patches/server/0014-Toggle-tick-level-when-empty.patch
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Thu, 4 May 2023 19:53:33 +0300
|
||||||
|
Subject: [PATCH] Toggle tick level when empty
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 6d7356cc07da58b1cef8d8963e790251d765de2c..601b9867d839f4928ba993ee8f00df9c330a0fe3 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -148,10 +148,12 @@ public class KaiijuWorldConfig {
|
||||||
|
|
||||||
|
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||||
|
public boolean optimizeHoppers = true;
|
||||||
|
+ public boolean tickWhenEmpty = true;
|
||||||
|
|
||||||
|
private void optimizationSettings() {
|
||||||
|
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
|
optimizeHoppers = getBoolean("optimization.optimize-hoppers", optimizeHoppers);
|
||||||
|
+ tickWhenEmpty = getBoolean("optimization.tick-when-empty", tickWhenEmpty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
index 3950b404482b0c6244141301e6ee3b4013327b2b..ca065f1600713a7f509e54580c625287e94d1e40 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -942,7 +942,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
timings.doSounds.stopTiming(); // Spigot
|
||||||
|
regionizedWorldData.setHandlingTick(false); // Folia - regionised ticking
|
||||||
|
gameprofilerfiller.pop();
|
||||||
|
- boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
|
||||||
|
+ boolean flag = kaiijuConfig.tickWhenEmpty || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players // Kaiiju - i don't think so
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
this.resetEmptyTime();
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 7 May 2023 20:04:06 +0300
|
||||||
|
Subject: [PATCH] Toggle break redstone on top of trap doors early
|
||||||
|
|
||||||
|
That patch break vanilla mechanics such as portal slicing.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 601b9867d839f4928ba993ee8f00df9c330a0fe3..e7ee85b09aa4438868e068551280b13e84cdfdb8 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -157,8 +157,10 @@ public class KaiijuWorldConfig {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
+ public boolean breakRedstoneOnTopOfTrapDoorsEarly = true;
|
||||||
|
|
||||||
|
private void gameplaySettings() {
|
||||||
|
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||||
|
+ breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java b/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java
|
||||||
|
index b9e3c9cd709d42bced85436720ccc7b9c7e49552..5e6d64408a5da3f337d32bb8ac5ac2532b04490c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java
|
||||||
|
@@ -125,6 +125,7 @@ public class TrapDoorBlock extends HorizontalDirectionalBlock implements SimpleW
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
boolean open = (Boolean) state.getValue(TrapDoorBlock.OPEN) != flag1; // Paper - break redstone on trapdoors early
|
||||||
|
+ if (world.kaiijuConfig.breakRedstoneOnTopOfTrapDoorsEarly) { // Kaiiju - trigger break redstone on trapdoors early
|
||||||
|
// Paper start - break redstone on trapdoors early
|
||||||
|
// note: this must run before any state for this block/its neighborus are written to the world
|
||||||
|
// we allow the redstone event to fire so that plugins can block
|
||||||
|
@@ -143,6 +144,7 @@ public class TrapDoorBlock extends HorizontalDirectionalBlock implements SimpleW
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Paper end - break redstone on trapdoors early
|
||||||
|
+ } // Kaiiju - trigger break redstone on trapdoors early
|
||||||
|
if (open) { // Paper - break redstone on trapdoors early
|
||||||
|
state = (BlockState) state.setValue(TrapDoorBlock.OPEN, flag1);
|
||||||
|
this.playSound((Player) null, world, pos, flag1);
|
||||||
141
patches/server/0016-Add-SIMD-utilities.patch
Normal file
141
patches/server/0016-Add-SIMD-utilities.patch
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Thu, 11 May 2023 05:02:40 +0300
|
||||||
|
Subject: [PATCH] Add SIMD utilities
|
||||||
|
|
||||||
|
Patch from Pufferfish
|
||||||
|
|
||||||
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
|
index 07efc7e9593f619c3b71bb3936077a66a0f2964d..8aa2f328f7fe3d85f7ddf05fa0259061eb950fff 100644
|
||||||
|
--- a/build.gradle.kts
|
||||||
|
+++ b/build.gradle.kts
|
||||||
|
@@ -68,6 +68,12 @@ dependencies {
|
||||||
|
}
|
||||||
|
|
||||||
|
val craftbukkitPackageVersion = "1_20_R2" // Paper
|
||||||
|
+// Kaiiju start - Pufferfish - SIMD utilities
|
||||||
|
+tasks.withType<JavaCompile> {
|
||||||
|
+ val compilerArgs = options.compilerArgs
|
||||||
|
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||||
|
+}
|
||||||
|
+// Kaiiju end
|
||||||
|
tasks.jar {
|
||||||
|
archiveClassifier.set("dev")
|
||||||
|
|
||||||
|
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..586b4cd007b3b106966524e2697edddf88e3ac9d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||||
|
@@ -0,0 +1,59 @@
|
||||||
|
+package gg.pufferfish.pufferfish.simd;
|
||||||
|
+
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import java.util.logging.Level;
|
||||||
|
+import java.util.logging.Logger;
|
||||||
|
+import jdk.incubator.vector.FloatVector;
|
||||||
|
+import jdk.incubator.vector.IntVector;
|
||||||
|
+import jdk.incubator.vector.VectorSpecies;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Basically, java is annoying and we have to push this out to its own class.
|
||||||
|
+ */
|
||||||
|
+public class SIMDChecker {
|
||||||
|
+
|
||||||
|
+ public static boolean canEnable(Logger logger) {
|
||||||
|
+ try {
|
||||||
|
+ if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19) {
|
||||||
|
+ return false;
|
||||||
|
+ } else {
|
||||||
|
+ SIMDDetection.testRun = true;
|
||||||
|
+
|
||||||
|
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
|
||||||
|
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
|
||||||
|
+
|
||||||
|
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + ISPEC.vectorBitSize() + " bits (int)");
|
||||||
|
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
|
||||||
|
+
|
||||||
|
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
|
||||||
|
+ logger.log(Level.WARNING, "SIMD is not properly supported on this system!");
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void simdWarning() {
|
||||||
|
+ // Attempt to detect vectorization
|
||||||
|
+ try {
|
||||||
|
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(Bukkit.getLogger());
|
||||||
|
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19;
|
||||||
|
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||||
|
+ ignored.printStackTrace();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (SIMDDetection.isEnabled) {
|
||||||
|
+ Bukkit.getLogger().info("SIMD operations detected as functional. Will replace some operations with faster versions.");
|
||||||
|
+ } else if (SIMDDetection.versionLimited) {
|
||||||
|
+ Bukkit.getLogger().warning("Will not enable SIMD! These optimizations are only safely supported on Java 17, Java 18, and Java 19.");
|
||||||
|
+ } else {
|
||||||
|
+ Bukkit.getLogger().warning("SIMD operations are available for your server, but are not configured!");
|
||||||
|
+ Bukkit.getLogger().warning("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");
|
||||||
|
+ Bukkit.getLogger().warning("If you have already added this flag, then SIMD operations are not supported on your JVM or CPU.");
|
||||||
|
+ Bukkit.getLogger().warning("Debug: Java: " + System.getProperty("java.version") + ", test run: " + SIMDDetection.testRun);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..758fa97304a32bf17935c86dc03cbf50606935d8
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||||
|
@@ -0,0 +1,32 @@
|
||||||
|
+package gg.pufferfish.pufferfish.simd;
|
||||||
|
+
|
||||||
|
+import java.util.logging.Logger;
|
||||||
|
+
|
||||||
|
+public class SIMDDetection {
|
||||||
|
+
|
||||||
|
+ public static boolean isEnabled = false;
|
||||||
|
+ public static boolean versionLimited = false;
|
||||||
|
+ public static boolean testRun = false;
|
||||||
|
+
|
||||||
|
+ public static boolean canEnable(Logger logger) {
|
||||||
|
+ try {
|
||||||
|
+ return SIMDChecker.canEnable(logger);
|
||||||
|
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int getJavaVersion() {
|
||||||
|
+ // https://stackoverflow.com/a/2591122
|
||||||
|
+ String version = System.getProperty("java.version");
|
||||||
|
+ if(version.startsWith("1.")) {
|
||||||
|
+ version = version.substring(2, 3);
|
||||||
|
+ } else {
|
||||||
|
+ int dot = version.indexOf(".");
|
||||||
|
+ if(dot != -1) { version = version.substring(0, dot); }
|
||||||
|
+ }
|
||||||
|
+ version = version.split("-")[0]; // Azul is stupid
|
||||||
|
+ return Integer.parseInt(version);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
index dcf8fd8ab06b10ecffae7332bc7e1a941b6a27a1..31397e53ab76266356c7582280d264c0f1df2504 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
@@ -225,6 +225,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||||
|
DedicatedServer.LOGGER.error("Unable to load server configuration", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
+ gg.pufferfish.pufferfish.simd.SIMDChecker.simdWarning();
|
||||||
|
dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands();
|
||||||
|
// Kaiiju end
|
||||||
|
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now
|
||||||
37
patches/server/0017-Toggle-shared-random-for-players.patch
Normal file
37
patches/server/0017-Toggle-shared-random-for-players.patch
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Thu, 11 May 2023 17:12:34 +0300
|
||||||
|
Subject: [PATCH] Toggle shared random for players
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index 2aa40f154c48ee7558b0efdc3bf26e205bb9f799..23b43de57a07b2b7b180f1aabd17e7e30830b521 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -214,8 +214,10 @@ public class KaiijuConfig {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String serverModName = "Kaiiju";
|
||||||
|
+ public static boolean sharedRandomForPlayers = true;
|
||||||
|
|
||||||
|
private static void gameplaySettings() {
|
||||||
|
serverModName = getString("gameplay.server-mod-name", serverModName);
|
||||||
|
+ sharedRandomForPlayers = getBoolean("gameplay.shared-random-for-players", sharedRandomForPlayers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
index e1b6673729e71bdc929bc7b76983108a59e55891..01d1360d7e3a31b985f24f825d304ae75a99814c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -555,6 +555,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
this.bb = Entity.INITIAL_AABB;
|
||||||
|
this.stuckSpeedMultiplier = Vec3.ZERO;
|
||||||
|
this.nextStep = 1.0F;
|
||||||
|
+ // Kaiiju start - Toggle shared random for players
|
||||||
|
+ if (!dev.kaiijumc.kaiiju.KaiijuConfig.sharedRandomForPlayers && this instanceof Player)
|
||||||
|
+ this.random = RandomSource.create();
|
||||||
|
+ else
|
||||||
|
+ // Kaiiju end
|
||||||
|
this.random = SHARED_RANDOM; // Paper
|
||||||
|
this.remainingFireTicks = -this.getFireImmuneTicks();
|
||||||
|
this.fluidHeight = new Object2DoubleArrayMap(2);
|
||||||
42
patches/server/0018-Kick-player-instead-of-crashing.patch
Normal file
42
patches/server/0018-Kick-player-instead-of-crashing.patch
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 14 May 2023 18:50:57 +0300
|
||||||
|
Subject: [PATCH] Kick player instead of crashing
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
|
||||||
|
index 07abf5a326cc7aa8a449b74bd7ac8a43b98528c0..eb875ee3d5bcbf90719eafc1c873189f1bfc26dd 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
|
||||||
|
@@ -484,7 +484,12 @@ public class RegionizedPlayerChunkLoader {
|
||||||
|
PlayerChunkSender.sendChunk(this.player.connection, this.world, this.world.getChunkIfLoaded(chunkX, chunkZ));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- throw new IllegalStateException();
|
||||||
|
+ // Kaiiju - Kick player instead of crashing
|
||||||
|
+ String errorMsg = "Already sent chunk [" + chunkX + ", " + chunkZ + "] in world " + this.world;
|
||||||
|
+ this.player.getBukkitEntity().kickPlayer(errorMsg);
|
||||||
|
+ org.bukkit.Bukkit.getLogger().severe(errorMsg);
|
||||||
|
+ // throw new IllegalStateException();
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendUnloadChunk(final int chunkX, final int chunkZ) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||||
|
index 047e817eae19800d146970a3ab44913ea1d17c89..59858f2dc91ab50fff99f2f23eedfb99207b29cf 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||||
|
@@ -102,7 +102,12 @@ public class ChunkHolder {
|
||||||
|
|
||||||
|
public void addPlayer(ServerPlayer player) {
|
||||||
|
if (!this.playersSentChunkTo.add(player)) {
|
||||||
|
- throw new IllegalStateException("Already sent chunk " + this.pos + " in world '" + this.chunkMap.level.getWorld().getName() + "' to player " + player);
|
||||||
|
+ // Kaiiju start - Kick player instead of crashing
|
||||||
|
+ String errorMsg = "Already sent chunk " + this.pos + " in world " + this.chunkMap.level.getWorld().getName();
|
||||||
|
+ player.getBukkitEntity().kickPlayer(errorMsg);
|
||||||
|
+ org.bukkit.Bukkit.getLogger().severe(errorMsg);
|
||||||
|
+ //throw new IllegalStateException("Already sent chunk " + this.pos + " in world '" + this.chunkMap.level.getWorld().getName() + "' to player " + player);
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Thu, 18 May 2023 15:50:40 +0300
|
||||||
|
Subject: [PATCH] Toggle fix TripWire state inconsistency
|
||||||
|
|
||||||
|
This allow string duplication
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index e7ee85b09aa4438868e068551280b13e84cdfdb8..8d7821d8b1a3615eaef1073d9dab690559b85f81 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -158,9 +158,11 @@ public class KaiijuWorldConfig {
|
||||||
|
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
public boolean breakRedstoneOnTopOfTrapDoorsEarly = true;
|
||||||
|
+ public boolean fixTripWireStateInconsistency = true;
|
||||||
|
|
||||||
|
private void gameplaySettings() {
|
||||||
|
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||||
|
breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
|
||||||
|
+ fixTripWireStateInconsistency = getBoolean("gameplay.fix-tripwire-state-inconsistency", fixTripWireStateInconsistency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
|
||||||
|
index cb2ff8d94308c637a498d2737f86f6af4c9c1b83..84c407dfd19924d12f1c25addbb613e607445fd9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
|
||||||
|
@@ -78,7 +78,7 @@ public class TripWireBlock extends Block {
|
||||||
|
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moved) {
|
||||||
|
if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent adjacent tripwires from updating
|
||||||
|
if (!moved && !state.is(newState.getBlock())) {
|
||||||
|
- this.updateSource(world, pos, (BlockState) state.setValue(TripWireBlock.POWERED, true), true); // Paper - fix state inconsistency
|
||||||
|
+ this.updateSource(world, pos, (BlockState) state.setValue(TripWireBlock.POWERED, true), world.kaiijuConfig.fixTripWireStateInconsistency); // Paper - fix state inconsistency // Kaiiju - Toggle this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,370 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Sun, 21 May 2023 15:55:04 +0200
|
||||||
|
Subject: [PATCH] Entity ticking throttling & removal to prevent lag.
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
|
index 5e79a464c912466952547cc294557821b6ff3576..6557a587f51f421b477557b17883578542fa1baf 100644
|
||||||
|
--- a/build.gradle.kts
|
||||||
|
+++ b/build.gradle.kts
|
||||||
|
@@ -23,6 +23,7 @@ dependencies {
|
||||||
|
implementation("com.github.luben:zstd-jni:1.5.4-1")
|
||||||
|
implementation("org.lz4:lz4-java:1.8.0")
|
||||||
|
// Kaiiju end
|
||||||
|
+ implementation("io.github.classgraph:classgraph:4.8.158") // Kaiiju - Entity throttling & Removal
|
||||||
|
// Paper start
|
||||||
|
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||||
|
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..887ea85ca2a03796bfa5bf62f27d1a7abd7fbc29
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
|
||||||
|
@@ -0,0 +1,139 @@
|
||||||
|
+package dev.kaiijumc.kaiiju;
|
||||||
|
+
|
||||||
|
+import java.io.File;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+import java.util.Map;
|
||||||
|
+import java.util.HashMap;
|
||||||
|
+import java.util.logging.Level;
|
||||||
|
+
|
||||||
|
+import com.google.common.base.Throwables;
|
||||||
|
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
+import io.github.classgraph.ClassGraph;
|
||||||
|
+import io.github.classgraph.ClassInfo;
|
||||||
|
+import io.github.classgraph.ScanResult;
|
||||||
|
+import org.slf4j.Logger;
|
||||||
|
+
|
||||||
|
+import com.mojang.logging.LogUtils;
|
||||||
|
+import net.minecraft.world.entity.Entity;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
+
|
||||||
|
+@SuppressWarnings("unused")
|
||||||
|
+public class KaiijuEntityLimits {
|
||||||
|
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
+
|
||||||
|
+ protected static final String HEADER =
|
||||||
|
+ "Per region entity limits for Kaiiju.\n"
|
||||||
|
+ + "If there are more of particular entity type in a region than limit, entity ticking will be throttled.\n"
|
||||||
|
+ + "Example: for Wither limit 100 & 300 Withers in a region -> 100 Withers tick every tick & every Wither ticks every 3 ticks.\n"
|
||||||
|
+ + "Available entities: GlowSquid, Ambient, Bat, Animal, Bee, Cat, Chicken, Cod, Cow, Dolphin, Fish, FishSchool, Fox, Golem, IronGolem, "
|
||||||
|
+ + "MushroomCow, Ocelot, Panda, Parrot, Perchable, Pig, PolarBear, PufferFish, Rabbit, Salmon, Sheep, Snowman, Squid, TropicalFish, Turtle, "
|
||||||
|
+ + "WaterAnimal, Wolf, Allay, Axolotl, Camel, Frog, Tadpole, Goat, Horse, HorseAbstract, HorseChestedAbstract, HorseDonkey, HorseMule, "
|
||||||
|
+ + "HorseSkeleton, HorseZombie, Llama, LlamaTrader, Sniffer, EnderCrystal, EnderDragon, Wither, ArmorStand, Hanging, ItemFrame, Leash, "
|
||||||
|
+ + "Painting, GlowItemFrame, FallingBlock, Item, TNTPrimed, Blaze, CaveSpider, Creeper, Drowned, Enderman, Endermite, Evoker, Ghast, "
|
||||||
|
+ + "GiantZombie, Guardian, GuardianElder, IllagerAbstract, IllagerIllusioner, IllagerWizard, MagmaCube, Monster, MonsterPatrolling, Phantom, "
|
||||||
|
+ + "PigZombie, Pillager, Ravager, Shulker, Silverfish, Skeleton, SkeletonAbstract, SkeletonStray, SkeletonWither, Slime, Spider, Strider, Vex, "
|
||||||
|
+ + "Vindicator, Witch, Zoglin, Zombie, ZombieHusk, ZombieVillager, Hoglin, Piglin, PiglinAbstract, PiglinBrute, Warden, Villager, "
|
||||||
|
+ + "VillagerTrader, Arrow, DragonFireball, Egg, EnderPearl, EnderSignal, EvokerFangs, Fireball, FireballFireball, Fireworks, FishingHook, "
|
||||||
|
+ + "LargeFireball, LlamaSpit, Potion, Projectile, ProjectileThrowable, ShulkerBullet, SmallFireball, Snowball, SpectralArrow, ThrownExpBottle, "
|
||||||
|
+ + "ThrownTrident, TippedArrow, WitherSkull, Raider, ChestBoat, Boat, MinecartAbstract, MinecartChest, MinecartCommandBlock, MinecartContainer, "
|
||||||
|
+ + "MinecartFurnace, MinecartHopper, MinecartMobSpawner, MinecartRideable, MinecartTNT\n";
|
||||||
|
+ protected static File ENTITY_LIMITS_FILE;
|
||||||
|
+ public static YamlConfiguration entityLimitsConfig;
|
||||||
|
+
|
||||||
|
+ protected static Map<Class<? extends Entity>, EntityLimit> entityLimits;
|
||||||
|
+
|
||||||
|
+ static final String ENTITY_PREFIX = "Entity";
|
||||||
|
+
|
||||||
|
+ public static void init(File entityLimitsFile) {
|
||||||
|
+ init(entityLimitsFile, true);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void reload(File entityLimitsFile) {
|
||||||
|
+ init(entityLimitsFile, false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void init(File entityLimitsFile, boolean setup) {
|
||||||
|
+ ENTITY_LIMITS_FILE = entityLimitsFile;
|
||||||
|
+ entityLimitsConfig = new YamlConfiguration();
|
||||||
|
+
|
||||||
|
+ if (entityLimitsFile.exists()) {
|
||||||
|
+ try {
|
||||||
|
+ entityLimitsConfig.load(ENTITY_LIMITS_FILE);
|
||||||
|
+ } catch (InvalidConfigurationException ex) {
|
||||||
|
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load kaiiju_entity_limits.yml, please correct your syntax errors", ex);
|
||||||
|
+ throw Throwables.propagate(ex);
|
||||||
|
+ } catch (IOException ignore) {}
|
||||||
|
+ } else {
|
||||||
|
+ if (setup) {
|
||||||
|
+ entityLimitsConfig.options().header(HEADER);
|
||||||
|
+ entityLimitsConfig.options().copyDefaults(true);
|
||||||
|
+ entityLimitsConfig.set("Wither.limit", 1000);
|
||||||
|
+ entityLimitsConfig.set("Wither.removal", 5000);
|
||||||
|
+ entityLimitsConfig.set("Axolotl.limit", 1000);
|
||||||
|
+ entityLimitsConfig.set("Axolotl.removal", 5000);
|
||||||
|
+ try {
|
||||||
|
+ entityLimitsConfig.save(ENTITY_LIMITS_FILE);
|
||||||
|
+ } catch (IOException ex) {
|
||||||
|
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + ENTITY_LIMITS_FILE, ex);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ entityLimits = new Object2ObjectOpenHashMap<>();
|
||||||
|
+ try (ScanResult scanResult = new ClassGraph().enableAllInfo().acceptPackages("net.minecraft.world.entity").scan()) {
|
||||||
|
+ Map<String, ClassInfo> entityClasses = new HashMap<>();
|
||||||
|
+ for (ClassInfo classInfo : scanResult.getAllClasses()) {
|
||||||
|
+ Class<?> entityClass = Class.forName(classInfo.getName());
|
||||||
|
+ if (Entity.class.isAssignableFrom(entityClass)) {
|
||||||
|
+ String entityName = extractEntityName(entityClass.getSimpleName());
|
||||||
|
+ entityClasses.put(entityName, classInfo);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (String key : entityLimitsConfig.getKeys(false)) {
|
||||||
|
+ if (!entityClasses.containsKey(key)) {
|
||||||
|
+ LOGGER.error("Unknown entity '" + key + "' in kaiiju-entity-limits.yml, skipping");
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ int limit = entityLimitsConfig.getInt(key + ".limit");
|
||||||
|
+ int removal = entityLimitsConfig.getInt(key + ".removal");
|
||||||
|
+
|
||||||
|
+ if (limit < 1) {
|
||||||
|
+ LOGGER.error(key + " has a limit less than the minimum of 1, ignoring");
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (removal <= limit && removal != -1) {
|
||||||
|
+ LOGGER.error(key + " has a removal limit that is less than or equal to its limit, setting removal to limit * 10");
|
||||||
|
+ removal = limit * 10;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ entityLimits.put((Class<? extends Entity>) Class.forName(entityClasses.get(key).getName()), new EntityLimit(limit, removal));
|
||||||
|
+ }
|
||||||
|
+ } catch (ClassNotFoundException e) {
|
||||||
|
+ e.printStackTrace();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static EntityLimit getEntityLimit(Entity entity) {
|
||||||
|
+ return entityLimits.get(entity.getClass());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static String extractEntityName(String input) {
|
||||||
|
+ int prefixLength = ENTITY_PREFIX.length();
|
||||||
|
+
|
||||||
|
+ if (input.length() <= prefixLength || !input.startsWith(ENTITY_PREFIX)) {
|
||||||
|
+ return input;
|
||||||
|
+ } else {
|
||||||
|
+ return input.substring(prefixLength);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public record EntityLimit(int limit, int removal) {
|
||||||
|
+ @Override
|
||||||
|
+ public String toString() {
|
||||||
|
+ return "EntityLimit{limit=" + limit + ", removal=" + removal + "}";
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..eb690efacf083e4ff3e321578b12c534e6a40196
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java
|
||||||
|
@@ -0,0 +1,84 @@
|
||||||
|
+package dev.kaiijumc.kaiiju;
|
||||||
|
+
|
||||||
|
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
+import net.minecraft.world.entity.Entity;
|
||||||
|
+import io.papermc.paper.threadedregions.RegionizedWorldData;
|
||||||
|
+
|
||||||
|
+public class KaiijuEntityThrottler {
|
||||||
|
+ private static class TickInfo {
|
||||||
|
+ int currentTick;
|
||||||
|
+ int continueFrom;
|
||||||
|
+ int toTick;
|
||||||
|
+ int toRemove;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static class EntityThrottlerReturn {
|
||||||
|
+ public boolean skip;
|
||||||
|
+ public boolean remove;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private final Object2ObjectOpenHashMap<KaiijuEntityLimits.EntityLimit, TickInfo> entityLimitTickInfoMap = new Object2ObjectOpenHashMap<>();
|
||||||
|
+
|
||||||
|
+ public void tickLimiterStart() {
|
||||||
|
+ for (TickInfo tickInfo : entityLimitTickInfoMap.values()) {
|
||||||
|
+ tickInfo.currentTick = 0;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public EntityThrottlerReturn tickLimiterShouldSkip(Entity entity) {
|
||||||
|
+ EntityThrottlerReturn retVal = new EntityThrottlerReturn();
|
||||||
|
+ if (entity.isRemoved()) return retVal;
|
||||||
|
+ KaiijuEntityLimits.EntityLimit entityLimit = KaiijuEntityLimits.getEntityLimit(entity);
|
||||||
|
+
|
||||||
|
+ if (entityLimit != null) {
|
||||||
|
+ TickInfo tickInfo = entityLimitTickInfoMap.computeIfAbsent(entityLimit, el -> {
|
||||||
|
+ TickInfo newTickInfo = new TickInfo();
|
||||||
|
+ newTickInfo.toTick = entityLimit.limit();
|
||||||
|
+ return newTickInfo;
|
||||||
|
+ });
|
||||||
|
+
|
||||||
|
+ tickInfo.currentTick++;
|
||||||
|
+ if (tickInfo.currentTick <= tickInfo.toRemove && entityLimit.removal() > 0) {
|
||||||
|
+ retVal.skip = false;
|
||||||
|
+ retVal.remove = true;
|
||||||
|
+ return retVal;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (tickInfo.currentTick < tickInfo.continueFrom) {
|
||||||
|
+ retVal.skip = true;
|
||||||
|
+ return retVal;
|
||||||
|
+ }
|
||||||
|
+ if (tickInfo.currentTick - tickInfo.continueFrom < tickInfo.toTick) {
|
||||||
|
+ retVal.skip = false;
|
||||||
|
+ return retVal;
|
||||||
|
+ }
|
||||||
|
+ retVal.skip = true;
|
||||||
|
+ return retVal;
|
||||||
|
+ } else {
|
||||||
|
+ retVal.skip = false;
|
||||||
|
+ return retVal;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void tickLimiterFinish(RegionizedWorldData regionizedWorldData) {
|
||||||
|
+ for (var entry : entityLimitTickInfoMap.entrySet()) {
|
||||||
|
+ KaiijuEntityLimits.EntityLimit entityLimit = entry.getKey();
|
||||||
|
+ TickInfo tickInfo = entry.getValue();
|
||||||
|
+
|
||||||
|
+ int additionals = 0;
|
||||||
|
+ int nextContinueFrom = tickInfo.continueFrom + tickInfo.toTick;
|
||||||
|
+ if (nextContinueFrom >= tickInfo.currentTick) {
|
||||||
|
+ additionals = entityLimit.limit() - (tickInfo.currentTick - tickInfo.continueFrom);
|
||||||
|
+ nextContinueFrom = 0;
|
||||||
|
+ }
|
||||||
|
+ tickInfo.continueFrom = nextContinueFrom;
|
||||||
|
+ tickInfo.toTick = entityLimit.limit() + additionals;
|
||||||
|
+
|
||||||
|
+ if (tickInfo.toRemove == 0 && tickInfo.currentTick > entityLimit.removal()) {
|
||||||
|
+ tickInfo.toRemove = tickInfo.currentTick - entityLimit.removal();
|
||||||
|
+ } else if (tickInfo.toRemove != 0) {
|
||||||
|
+ tickInfo.toRemove = 0;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 8d7821d8b1a3615eaef1073d9dab690559b85f81..816db23fa64aab69e3034484c00645ebd0479978 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -149,11 +149,13 @@ public class KaiijuWorldConfig {
|
||||||
|
public boolean shulkerBoxDropContentsWhenDestroyed = true;
|
||||||
|
public boolean optimizeHoppers = true;
|
||||||
|
public boolean tickWhenEmpty = true;
|
||||||
|
+ public boolean enableEntityThrottling = false;
|
||||||
|
|
||||||
|
private void optimizationSettings() {
|
||||||
|
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
|
optimizeHoppers = getBoolean("optimization.optimize-hoppers", optimizeHoppers);
|
||||||
|
tickWhenEmpty = getBoolean("optimization.tick-when-empty", tickWhenEmpty);
|
||||||
|
+ enableEntityThrottling = getBoolean("optimization.enable-entity-throttling", enableEntityThrottling);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java b/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
||||||
|
index 6fac162e0ec057af9f3336314d5663554cef0490..efecc7e132c67577577c99bfcf98e2b4ddae14ab 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/command/KaiijuCommand.java
|
||||||
|
@@ -1,6 +1,7 @@
|
||||||
|
package dev.kaiijumc.kaiiju.command;
|
||||||
|
|
||||||
|
import dev.kaiijumc.kaiiju.KaiijuConfig;
|
||||||
|
+import dev.kaiijumc.kaiiju.KaiijuEntityLimits;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
@@ -48,6 +49,7 @@ public class KaiijuCommand extends Command {
|
||||||
|
|
||||||
|
MinecraftServer console = MinecraftServer.getServer();
|
||||||
|
KaiijuConfig.reload((File) console.options.valueOf("kaiiju-settings"));
|
||||||
|
+ KaiijuEntityLimits.reload((File) console.options.valueOf("kaiiju-entity-limits"));
|
||||||
|
for (ServerLevel level : console.getAllLevels()) {
|
||||||
|
level.kaiijuConfig.reload();
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||||
|
index 7ca275826609bcf96f103a8c50beaa47c3b4068b..e895fad608e3a166cf9c800f16edb59bf9a42947 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||||
|
@@ -331,6 +331,7 @@ public final class RegionizedWorldData {
|
||||||
|
private final ReferenceList<Entity> toProcessTrackingUnloading = new ReferenceList<>();
|
||||||
|
private final IteratorSafeOrderedReferenceSet<Entity> entityTickList = new IteratorSafeOrderedReferenceSet<>();
|
||||||
|
private final IteratorSafeOrderedReferenceSet<Mob> navigatingMobs = new IteratorSafeOrderedReferenceSet<>();
|
||||||
|
+ public final dev.kaiijumc.kaiiju.KaiijuEntityThrottler entityThrottler = new dev.kaiijumc.kaiiju.KaiijuEntityThrottler(); // Kaiiju
|
||||||
|
|
||||||
|
// block ticking
|
||||||
|
private final ObjectLinkedOpenHashSet<BlockEventData> blockEvents = new ObjectLinkedOpenHashSet<>();
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
index 31397e53ab76266356c7582280d264c0f1df2504..4d077e459f385f86a0f35dd72d4fdc3a37961da9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
@@ -225,6 +225,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||||
|
DedicatedServer.LOGGER.error("Unable to load server configuration", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
+ try {
|
||||||
|
+ dev.kaiijumc.kaiiju.KaiijuEntityLimits.init((java.io.File) options.valueOf("kaiiju-entity-limits"));
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ DedicatedServer.LOGGER.error("Unable to load entity limits", e);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
gg.pufferfish.pufferfish.simd.SIMDChecker.simdWarning();
|
||||||
|
dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands();
|
||||||
|
// Kaiiju end
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
index ca065f1600713a7f509e54580c625287e94d1e40..6a3964d3120dfd98c7a434dc86e221aeebcb0145 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -968,6 +968,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
} finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.DRAGON_FIGHT_TICK); } // Folia - profiler
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (kaiijuConfig.enableEntityThrottling) regionizedWorldData.entityThrottler.tickLimiterStart(); // Kaiiju
|
||||||
|
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
|
||||||
|
timings.entityTick.startTiming(); // Spigot
|
||||||
|
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
|
||||||
|
@@ -991,6 +992,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
entity.stopRiding();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start
|
||||||
|
+ if (kaiijuConfig.enableEntityThrottling) {
|
||||||
|
+ dev.kaiijumc.kaiiju.KaiijuEntityThrottler.EntityThrottlerReturn throttle = regionizedWorldData.entityThrottler.tickLimiterShouldSkip(entity);
|
||||||
|
+ if (throttle.remove && !entity.hasCustomName()) entity.remove(Entity.RemovalReason.DISCARDED);
|
||||||
|
+ if (throttle.skip) return;
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
gameprofilerfiller.push("tick");
|
||||||
|
this.guardEntityTick(this::tickNonPassenger, entity);
|
||||||
|
gameprofilerfiller.pop();
|
||||||
|
@@ -999,6 +1007,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); } // Folia - profiler
|
||||||
|
+ if (kaiijuConfig.enableEntityThrottling) regionizedWorldData.entityThrottler.tickLimiterFinish(regionizedWorldData); // Kaiiju
|
||||||
|
timings.entityTick.stopTiming(); // Spigot
|
||||||
|
timings.tickEntities.stopTiming(); // Spigot
|
||||||
|
gameprofilerfiller.pop();
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
index d29fe7ac0c68b2d57a0c6b6d06bbb4436bfc4c14..b0e08392520fe21ef7b2dd66272da68411887223 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
@@ -179,6 +179,11 @@ public class Main {
|
||||||
|
.ofType(File.class)
|
||||||
|
.defaultsTo(new File("kaiiju.yml"))
|
||||||
|
.describedAs("Yml file");
|
||||||
|
+ acceptsAll(asList("kaiiju", "kaiiju-entity-limits"), "File for kaiiju's entity limits")
|
||||||
|
+ .withRequiredArg()
|
||||||
|
+ .ofType(File.class)
|
||||||
|
+ .defaultsTo(new File("kaiiju-entity-limits.yml"))
|
||||||
|
+ .describedAs("Yml file");
|
||||||
|
// Purpur end
|
||||||
|
|
||||||
|
// Paper start
|
||||||
53
patches/server/0021-Toggle-safe-teleportation.patch
Normal file
53
patches/server/0021-Toggle-safe-teleportation.patch
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Thu, 18 May 2023 20:05:49 +0300
|
||||||
|
Subject: [PATCH] Toggle safe teleportation
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 816db23fa64aab69e3034484c00645ebd0479978..7c6c74f95c2534624a928ccf6b0a4b9d2a5486ad 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -161,10 +161,12 @@ public class KaiijuWorldConfig {
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
public boolean breakRedstoneOnTopOfTrapDoorsEarly = true;
|
||||||
|
public boolean fixTripWireStateInconsistency = true;
|
||||||
|
+ public boolean safeTeleporting = true;
|
||||||
|
|
||||||
|
private void gameplaySettings() {
|
||||||
|
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||||
|
breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
|
||||||
|
fixTripWireStateInconsistency = getBoolean("gameplay.fix-tripwire-state-inconsistency", fixTripWireStateInconsistency);
|
||||||
|
+ safeTeleporting = getBoolean("gameplay.safe-teleportation", safeTeleporting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
index 01d1360d7e3a31b985f24f825d304ae75a99814c..f1f7a9b358eed87279f46eb49729214aaa8df6b3 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -4015,6 +4015,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
|
||||||
|
protected boolean tryEndPortal() {
|
||||||
|
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async");
|
||||||
|
+ if (!this.level.kaiijuConfig.safeTeleporting && !(this instanceof net.minecraft.world.entity.player.Player)) return false; // Kaiiju - Unsafe teleportation
|
||||||
|
BlockPos pos = this.portalBlock;
|
||||||
|
ServerLevel world = this.portalWorld;
|
||||||
|
this.portalBlock = null;
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||||
|
index 41d7cff39fc37955877668337689b4b26cd8c7cf..fe21ef0a2c451564694de915f6f4e61dbfeed712 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||||
|
@@ -53,6 +53,13 @@ public class EndPortalBlock extends BaseEntityBlock {
|
||||||
|
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Unsafe teleportation
|
||||||
|
+ if (!entity.level().kaiijuConfig.safeTeleporting && !(entity instanceof net.minecraft.world.entity.player.Player)) {
|
||||||
|
+ entity.endPortalLogicAsync();
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
// Paper start - move all of this logic into portal tick
|
||||||
|
entity.portalWorld = ((ServerLevel)world);
|
||||||
|
entity.portalBlock = pos.immutable();
|
||||||
46
patches/server/0022-Toggle-sand-duplication.patch
Normal file
46
patches/server/0022-Toggle-sand-duplication.patch
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 28 May 2023 01:51:52 +0300
|
||||||
|
Subject: [PATCH] Toggle sand duplication
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 7c6c74f95c2534624a928ccf6b0a4b9d2a5486ad..9f0095f2196133a8bcffd5306aa9ac0b99b2f8d7 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -162,11 +162,13 @@ public class KaiijuWorldConfig {
|
||||||
|
public boolean breakRedstoneOnTopOfTrapDoorsEarly = true;
|
||||||
|
public boolean fixTripWireStateInconsistency = true;
|
||||||
|
public boolean safeTeleporting = true;
|
||||||
|
+ public boolean sandDuplication = false;
|
||||||
|
|
||||||
|
private void gameplaySettings() {
|
||||||
|
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||||
|
breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
|
||||||
|
fixTripWireStateInconsistency = getBoolean("gameplay.fix-tripwire-state-inconsistency", fixTripWireStateInconsistency);
|
||||||
|
safeTeleporting = getBoolean("gameplay.safe-teleportation", safeTeleporting);
|
||||||
|
+ sandDuplication = getBoolean("gameplay.sand-duplication", sandDuplication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||||
|
index 31b59d7d439dbbd79605e5d078cbc9131b786ad9..629b12dbf855b6faa23a2fdf876cfd49e9228dc3 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||||
|
@@ -133,7 +133,7 @@ public class FallingBlockEntity extends Entity {
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
// Paper start - fix sand duping
|
||||||
|
- if (this.isRemoved()) {
|
||||||
|
+ if (!this.level().kaiijuConfig.sandDuplication && this.isRemoved()) { // Kaiiju - Toggle sand duplication
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Paper end - fix sand duping
|
||||||
|
@@ -150,7 +150,7 @@ public class FallingBlockEntity extends Entity {
|
||||||
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||||
|
|
||||||
|
// Paper start - fix sand duping
|
||||||
|
- if (this.isRemoved()) {
|
||||||
|
+ if (!this.level().kaiijuConfig.sandDuplication && this.isRemoved()) { // Kaiiju - Toggle sand duplication
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Paper end - fix sand duping
|
||||||
50
patches/server/0023-Vanilla-end-portal-teleportation.patch
Normal file
50
patches/server/0023-Vanilla-end-portal-teleportation.patch
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Fri, 19 May 2023 03:38:03 +0300
|
||||||
|
Subject: [PATCH] Vanilla end portal teleportation
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
index f1f7a9b358eed87279f46eb49729214aaa8df6b3..3dc840bf74e12a9e757a2adaa1d0b22d68ac3d26 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -4101,12 +4101,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||||
|
ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
|
||||||
|
(chunks) -> {
|
||||||
|
- ServerLevel.makeObsidianPlatform(destination, null, targetPos);
|
||||||
|
+ //ServerLevel.makeObsidianPlatform(destination, null, targetPos); // Kaiiju - Vanilla end teleportation - moved down
|
||||||
|
|
||||||
|
+ // Kaiiju start - Vanilla end teleportation
|
||||||
|
+ Vec3 finalPos;
|
||||||
|
+ if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(targetPos.below());
|
||||||
|
+ else finalPos = Vec3.atBottomCenterOf(targetPos);
|
||||||
|
+ // Kaiiju end
|
||||||
|
// the portal obsidian is placed at targetPos.y - 2, so if we want to place the entity
|
||||||
|
// on the obsidian, we need to spawn at targetPos.y - 1
|
||||||
|
portalInfoCompletable.complete(
|
||||||
|
- new PortalInfo(Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, 90.0f, 0.0f, destination, null)
|
||||||
|
+ new PortalInfo(finalPos, this.getDeltaMovement(), 90.0f, 0.0f, destination, null) // Kaiiju - Vanilla end teleportation
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
@@ -4293,6 +4298,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
if (!this.canPortalAsync(takePassengers)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
+ // Kaiiju start - sync end platform spawning & entity teleportation
|
||||||
|
+ final java.util.function.Consumer<Entity> tpComplete = type == PortalType.END && destination.getTypeKey() == LevelStem.END ?
|
||||||
|
+ e -> ServerLevel.makeObsidianPlatform(destination, null, ServerLevel.END_SPAWN_POINT) : teleportComplete;
|
||||||
|
+ // Kaiiju end
|
||||||
|
|
||||||
|
Vec3 initialPosition = this.position();
|
||||||
|
ChunkPos initialPositionChunk = new ChunkPos(
|
||||||
|
@@ -4351,7 +4360,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
// place
|
||||||
|
passengerTree.root.placeInAsync(
|
||||||
|
originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L),
|
||||||
|
- passengerTree, teleportComplete
|
||||||
|
+ passengerTree, tpComplete // Kaiiju - vanilla end teleportation
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Sat, 17 Jun 2023 21:03:04 +0300
|
||||||
|
Subject: [PATCH] Use Math.floor instead of fastfloor
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
|
index 2d6fc460c850c6d515794d2fa29324a448a985d1..d86355506a216389642d00bc0e0c6718ee2d0486 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
|
@@ -166,13 +166,19 @@ public final class MCUtil {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int fastFloor(double x) {
|
||||||
|
- int truncated = (int)x;
|
||||||
|
- return x < (double)truncated ? truncated - 1 : truncated;
|
||||||
|
+ // Kaiiju start - Use Math.floor instead of fastfloor
|
||||||
|
+ return (int)Math.floor(x); // Kaiiju
|
||||||
|
+ //int truncated = (int)x;
|
||||||
|
+ //return x < (double)truncated ? truncated - 1 : truncated;
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int fastFloor(float x) {
|
||||||
|
- int truncated = (int)x;
|
||||||
|
- return x < (double)truncated ? truncated - 1 : truncated;
|
||||||
|
+ // Kaiiju start - Use Math.floor instead of fastfloor
|
||||||
|
+ return (int)Math.floor(x); // Kaiiju
|
||||||
|
+ //int truncated = (int)x;
|
||||||
|
+ //return x < (double)truncated ? truncated - 1 : truncated;
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float normalizeYaw(float f) {
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 18 Jun 2023 18:10:19 +0300
|
||||||
|
Subject: [PATCH] Allow user to enable moving into unloaded chunks
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
|
index 1e3ae1cb466b4757ce7fc0bd0201190230756bcc..8cf64c784d1768275b94fd1e4125c7c8742b3d5d 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
|
@@ -473,14 +473,14 @@ public class WorldConfiguration extends ConfigurationPart {
|
||||||
|
// Folia start - region threading - force prevent moving into unloaded chunks
|
||||||
|
@PostProcess
|
||||||
|
public void postProcess() {
|
||||||
|
- this.preventMovingIntoUnloadedChunks = true;
|
||||||
|
+ //this.preventMovingIntoUnloadedChunks = true; // Kaiiju - Don't
|
||||||
|
}
|
||||||
|
// Folia end - region threading - force prevent moving into unloaded chunks
|
||||||
|
|
||||||
|
public AutosavePeriod autoSaveInterval = AutosavePeriod.def();
|
||||||
|
public int maxAutoSaveChunksPerTick = 24;
|
||||||
|
public int fixedChunkInhabitedTime = -1;
|
||||||
|
- public boolean preventMovingIntoUnloadedChunks = false;
|
||||||
|
+ public boolean preventMovingIntoUnloadedChunks = true; // Kaiiju - True not False
|
||||||
|
public Duration delayChunkUnloadsBy = Duration.of("10s");
|
||||||
|
public Reference2IntMap<EntityType<?>> entityPerChunkSaveLimit = Util.make(new Reference2IntOpenHashMap<>(BuiltInRegistries.ENTITY_TYPE.size()), map -> {
|
||||||
|
map.defaultReturnValue(-1);
|
||||||
20
patches/server/0026-Don-t-pathfind-outside-region.patch
Normal file
20
patches/server/0026-Don-t-pathfind-outside-region.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: Mon, 19 Jun 2023 01:49:00 +0300
|
||||||
|
Subject: [PATCH] Don't pathfind outside region
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||||
|
index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..98bf17441da3169d49de55fe89d79ebe250a2b7e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||||
|
@@ -107,7 +107,9 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||||
|
|
||||||
|
private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) {
|
||||||
|
BlockPos blockPos = walkTarget.getTarget().currentBlockPosition();
|
||||||
|
+ if (io.papermc.paper.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) // Kaiiju - Don't pathfind outside region
|
||||||
|
this.path = entity.getNavigation().createPath(blockPos, 0);
|
||||||
|
+ else this.path = null; // Kaiiju - Don't pathfind outside region
|
||||||
|
this.speedModifier = walkTarget.getSpeedModifier();
|
||||||
|
Brain<?> brain = entity.getBrain();
|
||||||
|
if (this.reachedTarget(entity, walkTarget)) {
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Mon, 19 Jun 2023 21:30:19 +0300
|
||||||
|
Subject: [PATCH] Don't spam recipe changes on update
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||||
|
index e38e2e5a7ddba9c140f362021b6be0b0974f7cd1..4cb589f03a7652238e70a9ef76c8cafd84ecc5d6 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||||
|
@@ -200,7 +200,7 @@ public class PlayerAdvancements {
|
||||||
|
|
||||||
|
if (advancementholder == null) {
|
||||||
|
if (!minecraftkey.getNamespace().equals("minecraft")) return; // CraftBukkit
|
||||||
|
- PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath);
|
||||||
|
+ //PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath); // Kaiiju - We already know, don't spam.
|
||||||
|
} else {
|
||||||
|
this.startProgress(advancementholder, advancementprogress);
|
||||||
|
this.progressChanged.add(advancementholder);
|
||||||
|
diff --git a/src/main/java/net/minecraft/stats/ServerRecipeBook.java b/src/main/java/net/minecraft/stats/ServerRecipeBook.java
|
||||||
|
index 4103ddf16164e3992fef0765d368282572537e29..fe69cd06457ada65ced4ee32b815360a435e6c55 100644
|
||||||
|
--- a/src/main/java/net/minecraft/stats/ServerRecipeBook.java
|
||||||
|
+++ b/src/main/java/net/minecraft/stats/ServerRecipeBook.java
|
||||||
|
@@ -125,7 +125,7 @@ public class ServerRecipeBook extends RecipeBook {
|
||||||
|
Optional<RecipeHolder<?>> optional = recipeManager.byKey(minecraftkey);
|
||||||
|
|
||||||
|
if (optional.isEmpty()) {
|
||||||
|
- ServerRecipeBook.LOGGER.error("Tried to load unrecognized recipe: {} removed now.", minecraftkey);
|
||||||
|
+ //ServerRecipeBook.LOGGER.error("Tried to load unrecognized recipe: {} removed now.", minecraftkey); // Kaiiju - We already know, don't spam.
|
||||||
|
} else {
|
||||||
|
handler.accept((RecipeHolder) optional.get());
|
||||||
|
}
|
||||||
38
patches/server/0028-Option-to-disable-vanish-api.patch
Normal file
38
patches/server/0028-Option-to-disable-vanish-api.patch
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Thu, 22 Jun 2023 00:14:47 +0200
|
||||||
|
Subject: [PATCH] Option to disable vanish api
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index 23b43de57a07b2b7b180f1aabd17e7e30830b521..59b41c29f42072ec2d3ba03b09e0ead897800ee1 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -210,7 +210,10 @@ public class KaiijuConfig {
|
||||||
|
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public static boolean disableVanishApi = false;
|
||||||
|
+
|
||||||
|
private static void optimizationSettings() {
|
||||||
|
+ disableVanishApi = getBoolean("optimization.disable-vanish-api", disableVanishApi);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String serverModName = "Kaiiju";
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
index 04e249699e1c1a82d4c94b94b815ffa8fd97a99e..fbb0723ebd7dfef04252de694dc29b979c563452 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
@@ -1376,7 +1376,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
|
// Folia end - region threading
|
||||||
|
|
||||||
|
// CraftBukkit start - respect vanish API
|
||||||
|
- if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSee(this.entity.getBukkitEntity()))) { // Folia - region threading
|
||||||
|
+ // Kaiiju start - don't respect vanish API >:D
|
||||||
|
+ boolean canSee = true;
|
||||||
|
+ if (flag && !dev.kaiijumc.kaiiju.KaiijuConfig.disableVanishApi) canSee = player.getBukkitEntity().canSee(this.entity.getBukkitEntity());
|
||||||
|
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !canSee) { // Folia - region threading
|
||||||
|
+ // Kaiiju end
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
34
patches/server/0029-Option-to-disable-player-stats.patch
Normal file
34
patches/server/0029-Option-to-disable-player-stats.patch
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Thu, 22 Jun 2023 00:17:57 +0200
|
||||||
|
Subject: [PATCH] Option to disable player stats
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index 59b41c29f42072ec2d3ba03b09e0ead897800ee1..b11a329ead2347917d24d932c9a1a826d288f5b6 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -211,9 +211,11 @@ public class KaiijuConfig {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean disableVanishApi = false;
|
||||||
|
+ public static boolean disablePlayerStats = false;
|
||||||
|
|
||||||
|
private static void optimizationSettings() {
|
||||||
|
disableVanishApi = getBoolean("optimization.disable-vanish-api", disableVanishApi);
|
||||||
|
+ disablePlayerStats = getBoolean("optimization.disable-player-stats", disablePlayerStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String serverModName = "Kaiiju";
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
index 42ff3d94ee451ced69c1059f0dbd45085489a60d..374dc5fd0ad15ace5314f2b9c675d1770a43f45a 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
@@ -2144,6 +2144,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void awardStat(Stat<?> stat, int amount) {
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disablePlayerStats) return; // Kaiiju - Disable player stats
|
||||||
|
this.stats.increment(this, stat, amount);
|
||||||
|
this.level().getCraftServer().getScoreboardManager().getScoreboardScores(stat, this.getScoreboardName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead
|
||||||
|
scoreboardscore.add(amount);
|
||||||
175
patches/server/0030-Option-to-disable-achievements.patch
Normal file
175
patches/server/0030-Option-to-disable-achievements.patch
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Thu, 22 Jun 2023 00:32:36 +0200
|
||||||
|
Subject: [PATCH] Option to disable achievements
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 9f0095f2196133a8bcffd5306aa9ac0b99b2f8d7..31d66bb2fcf4bb7262df2d8006e307fee92660ea 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -150,12 +150,14 @@ public class KaiijuWorldConfig {
|
||||||
|
public boolean optimizeHoppers = true;
|
||||||
|
public boolean tickWhenEmpty = true;
|
||||||
|
public boolean enableEntityThrottling = false;
|
||||||
|
+ public boolean disableAchievements = false;
|
||||||
|
|
||||||
|
private void optimizationSettings() {
|
||||||
|
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
|
optimizeHoppers = getBoolean("optimization.optimize-hoppers", optimizeHoppers);
|
||||||
|
tickWhenEmpty = getBoolean("optimization.tick-when-empty", tickWhenEmpty);
|
||||||
|
enableEntityThrottling = getBoolean("optimization.enable-entity-throttling", enableEntityThrottling);
|
||||||
|
+ disableAchievements = getBoolean("optimization.disable-achievements", disableAchievements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
index 374dc5fd0ad15ace5314f2b9c675d1770a43f45a..0a65f35f247a39e89d64721499162b419475da4f 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
@@ -800,7 +800,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onInsideBlock(BlockState state) {
|
||||||
|
- CriteriaTriggers.ENTER_BLOCK.trigger(this, state);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.ENTER_BLOCK.trigger(this, state); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -847,9 +847,9 @@ public class ServerPlayer extends Player {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- CriteriaTriggers.TICK.trigger(this);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.TICK.trigger(this); // Kaiiju
|
||||||
|
if (this.levitationStartPos != null) {
|
||||||
|
- CriteriaTriggers.LEVITATION.trigger(this, this.levitationStartPos, this.tickCount - this.levitationStartTime);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.LEVITATION.trigger(this, this.levitationStartPos, this.tickCount - this.levitationStartTime); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
this.trackStartFallingPosition();
|
||||||
|
@@ -924,7 +924,7 @@ public class ServerPlayer extends Player {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.tickCount % 20 == 0) {
|
||||||
|
- CriteriaTriggers.LOCATION.trigger(this);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.LOCATION.trigger(this); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border
|
||||||
|
@@ -953,7 +953,7 @@ public class ServerPlayer extends Player {
|
||||||
|
@Override
|
||||||
|
public void resetFallDistance() {
|
||||||
|
if (this.getHealth() > 0.0F && this.startingToFallPosition != null) {
|
||||||
|
- CriteriaTriggers.FALL_FROM_HEIGHT.trigger(this, this.startingToFallPosition);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.FALL_FROM_HEIGHT.trigger(this, this.startingToFallPosition); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
this.startingToFallPosition = null;
|
||||||
|
@@ -972,7 +972,7 @@ public class ServerPlayer extends Player {
|
||||||
|
if (this.enteredLavaOnVehiclePosition == null) {
|
||||||
|
this.enteredLavaOnVehiclePosition = this.position();
|
||||||
|
} else {
|
||||||
|
- CriteriaTriggers.RIDE_ENTITY_IN_LAVA_TRIGGER.trigger(this, this.enteredLavaOnVehiclePosition);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.RIDE_ENTITY_IN_LAVA_TRIGGER.trigger(this, this.enteredLavaOnVehiclePosition); // Kaiiju
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1176,7 +1176,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
|
this.handleTeamKill(s, s1, ObjectiveCriteria.TEAM_KILL);
|
||||||
|
this.handleTeamKill(s1, s, ObjectiveCriteria.KILLED_BY_TEAM);
|
||||||
|
- CriteriaTriggers.PLAYER_KILLED_ENTITY.trigger(this, entityKilled, damageSource);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.PLAYER_KILLED_ENTITY.trigger(this, entityKilled, damageSource); // Kaiiju
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1294,7 +1294,7 @@ public class ServerPlayer extends Player {
|
||||||
|
this.wonGame = false;
|
||||||
|
|
||||||
|
this.respawn((player) -> {
|
||||||
|
- CriteriaTriggers.CHANGED_DIMENSION.trigger(player, Level.END, Level.OVERWORLD);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.CHANGED_DIMENSION.trigger(player, Level.END, Level.OVERWORLD); // Kaiiju
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1788,14 +1788,14 @@ public class ServerPlayer extends Player {
|
||||||
|
maindimensionkey1 = resourcekey1;
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
- CriteriaTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1); // Kaiiju
|
||||||
|
if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) {
|
||||||
|
- CriteriaTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maindimensionkey == Level.NETHER && maindimensionkey1 == Level.OVERWORLD && this.enteredNetherPosition != null) {
|
||||||
|
// CraftBukkit end
|
||||||
|
- CriteriaTriggers.NETHER_TRAVEL.trigger(this, this.enteredNetherPosition);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.NETHER_TRAVEL.trigger(this, this.enteredNetherPosition); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maindimensionkey1 != Level.NETHER) { // CraftBukkit
|
||||||
|
@@ -1873,7 +1873,7 @@ public class ServerPlayer extends Player {
|
||||||
|
{
|
||||||
|
Either<Player.BedSleepingProblem, Unit> either = super.startSleepInBed(blockposition, force).ifRight((unit) -> {
|
||||||
|
this.awardStat(Stats.SLEEP_IN_BED);
|
||||||
|
- CriteriaTriggers.SLEPT_IN_BED.trigger(this);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.SLEPT_IN_BED.trigger(this); // Kaiiju
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!this.serverLevel().canSleepThroughNights()) {
|
||||||
|
@@ -2164,7 +2164,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void triggerRecipeCrafted(RecipeHolder<?> recipe, List<ItemStack> ingredients) {
|
||||||
|
- CriteriaTriggers.RECIPE_CRAFTED.trigger(this, recipe.id(), ingredients);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.RECIPE_CRAFTED.trigger(this, recipe.id(), ingredients); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -2293,14 +2293,14 @@ public class ServerPlayer extends Player {
|
||||||
|
this.levitationStartPos = this.position();
|
||||||
|
}
|
||||||
|
|
||||||
|
- CriteriaTriggers.EFFECTS_CHANGED.trigger(this, source);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.EFFECTS_CHANGED.trigger(this, source); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEffectUpdated(MobEffectInstance effect, boolean reapplyEffect, @Nullable Entity source) {
|
||||||
|
super.onEffectUpdated(effect, reapplyEffect, source);
|
||||||
|
this.connection.send(new ClientboundUpdateMobEffectPacket(this.getId(), effect));
|
||||||
|
- CriteriaTriggers.EFFECTS_CHANGED.trigger(this, source);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.EFFECTS_CHANGED.trigger(this, source); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -2311,7 +2311,7 @@ public class ServerPlayer extends Player {
|
||||||
|
this.levitationStartPos = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
- CriteriaTriggers.EFFECTS_CHANGED.trigger(this, (Entity) null);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.EFFECTS_CHANGED.trigger(this, (Entity) null); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -2856,7 +2856,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateUsingItem(ItemStack stack) {
|
||||||
|
- CriteriaTriggers.USING_ITEM.trigger(this, stack);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.USING_ITEM.trigger(this, stack); // Kaiiju
|
||||||
|
super.updateUsingItem(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2885,7 +2885,7 @@ public class ServerPlayer extends Player {
|
||||||
|
Entity entity = item.getOwner();
|
||||||
|
|
||||||
|
if (entity != null) {
|
||||||
|
- CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_PLAYER.trigger(this, item.getItem(), entity);
|
||||||
|
+ if (!this.level().kaiijuConfig.disableAchievements) CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_PLAYER.trigger(this, item.getItem(), entity); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
patches/server/0031-Option-to-disable-arm-swing-event.patch
Normal file
43
patches/server/0031-Option-to-disable-arm-swing-event.patch
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Thu, 22 Jun 2023 00:37:27 +0200
|
||||||
|
Subject: [PATCH] Option to disable arm swing event
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index b11a329ead2347917d24d932c9a1a826d288f5b6..2f3827441987528d79d9268002c7a7671faff429 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -212,10 +212,12 @@ public class KaiijuConfig {
|
||||||
|
|
||||||
|
public static boolean disableVanishApi = false;
|
||||||
|
public static boolean disablePlayerStats = false;
|
||||||
|
+ public static boolean disableArmSwingEvent = false;
|
||||||
|
|
||||||
|
private static void optimizationSettings() {
|
||||||
|
disableVanishApi = getBoolean("optimization.disable-vanish-api", disableVanishApi);
|
||||||
|
disablePlayerStats = getBoolean("optimization.disable-player-stats", disablePlayerStats);
|
||||||
|
+ disableArmSwingEvent = getBoolean("optimization.disable-arm-swing-event", disableArmSwingEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String serverModName = "Kaiiju";
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
index 10ce902a1ce857db5376c8318ba0e67b53883873..4e87165f0a155ace79d9c249c5546951db00dc39 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
@@ -2536,6 +2536,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||||
|
if (this.player.isImmobile()) return; // CraftBukkit
|
||||||
|
this.player.resetLastActionTime();
|
||||||
|
+ if (!dev.kaiijumc.kaiiju.KaiijuConfig.disableArmSwingEvent) { // Kaiiju
|
||||||
|
// CraftBukkit start - Raytrace to look for 'rogue armswings'
|
||||||
|
float f1 = this.player.getXRot();
|
||||||
|
float f2 = this.player.getYRot();
|
||||||
|
@@ -2568,6 +2569,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
// CraftBukkit end
|
||||||
|
+ } // Kaiiju
|
||||||
|
this.player.swing(packet.getHand());
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Thu, 22 Jun 2023 00:47:57 +0200
|
||||||
|
Subject: [PATCH] Option to disable creatures spawn events
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index 31d66bb2fcf4bb7262df2d8006e307fee92660ea..c9830912019079369268bfbf2c95de18ad598f52 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -151,6 +151,7 @@ public class KaiijuWorldConfig {
|
||||||
|
public boolean tickWhenEmpty = true;
|
||||||
|
public boolean enableEntityThrottling = false;
|
||||||
|
public boolean disableAchievements = false;
|
||||||
|
+ public boolean disableCreaturesSpawnEvents = false;
|
||||||
|
|
||||||
|
private void optimizationSettings() {
|
||||||
|
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
|
@@ -158,6 +159,7 @@ public class KaiijuWorldConfig {
|
||||||
|
tickWhenEmpty = getBoolean("optimization.tick-when-empty", tickWhenEmpty);
|
||||||
|
enableEntityThrottling = getBoolean("optimization.enable-entity-throttling", enableEntityThrottling);
|
||||||
|
disableAchievements = getBoolean("optimization.disable-achievements", disableAchievements);
|
||||||
|
+ disableCreaturesSpawnEvents = getBoolean("optimization.disable-creatures-spawn-events", disableCreaturesSpawnEvents);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
index 72a5973c6e150533ec70496d72b53c80a142eef7..891edd228699915f165ddf3ca4fcee502874780d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
@@ -540,7 +540,11 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
chunkRange = (chunkRange > viewDistance) ? viewDistance : chunkRange;
|
||||||
|
chunkRange = (chunkRange > DistanceManager.MOB_SPAWN_RANGE) ? DistanceManager.MOB_SPAWN_RANGE : chunkRange;
|
||||||
|
|
||||||
|
- com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange);
|
||||||
|
+ // Kaiiju start - disable creatures spawn events
|
||||||
|
+ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = null;
|
||||||
|
+ if (!this.level.kaiijuConfig.disableCreaturesSpawnEvents) {
|
||||||
|
+ event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange);
|
||||||
|
+ // Kaiiju end
|
||||||
|
event.callEvent();
|
||||||
|
if (event.isCancelled() || event.getSpawnRadius() < 0) {
|
||||||
|
regionizedWorldData.mobSpawnMap.remove(player); // Folia - region threading
|
||||||
|
@@ -548,14 +552,18 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
player.lastEntitySpawnRadiusSquared = -1.0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
+ // Kaiiju start - disable creatures spawn events
|
||||||
|
+ chunkRange = Math.min(event.getSpawnRadius(), DistanceManager.MOB_SPAWN_RANGE);
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
|
||||||
|
- int range = Math.min(event.getSpawnRadius(), DistanceManager.MOB_SPAWN_RANGE); // limit to max spawn range
|
||||||
|
+ int range = chunkRange; // limit to max spawn range // Kaiiju
|
||||||
|
int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX());
|
||||||
|
int chunkZ = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getZ());
|
||||||
|
|
||||||
|
regionizedWorldData.mobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range); // Folia - region threading
|
||||||
|
player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning
|
||||||
|
- player.playerNaturallySpawnedEvent = event;
|
||||||
|
+ if (!this.level.kaiijuConfig.disableCreaturesSpawnEvents) player.playerNaturallySpawnedEvent = event; // Kaiiju
|
||||||
|
}
|
||||||
|
// Paper end - optimise chunk tick iteration
|
||||||
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Thu, 22 Jun 2023 00:52:00 +0200
|
||||||
|
Subject: [PATCH] Option to disable dolphin swim to treasure
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index c9830912019079369268bfbf2c95de18ad598f52..e2fb7d7a7b3126d386b46442c115085d1974ac4e 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -152,6 +152,7 @@ public class KaiijuWorldConfig {
|
||||||
|
public boolean enableEntityThrottling = false;
|
||||||
|
public boolean disableAchievements = false;
|
||||||
|
public boolean disableCreaturesSpawnEvents = false;
|
||||||
|
+ public boolean disableDolphinSwimToTreasure = false;
|
||||||
|
|
||||||
|
private void optimizationSettings() {
|
||||||
|
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
|
||||||
|
@@ -160,6 +161,7 @@ public class KaiijuWorldConfig {
|
||||||
|
enableEntityThrottling = getBoolean("optimization.enable-entity-throttling", enableEntityThrottling);
|
||||||
|
disableAchievements = getBoolean("optimization.disable-achievements", disableAchievements);
|
||||||
|
disableCreaturesSpawnEvents = getBoolean("optimization.disable-creatures-spawn-events", disableCreaturesSpawnEvents);
|
||||||
|
+ disableDolphinSwimToTreasure = getBoolean("optimization.disable-dolphin-swim-to-treasure", disableDolphinSwimToTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fixVoidTrading = true;
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java
|
||||||
|
index 8448c5d778998390cf2b683f36e4e18ca7ffdc34..8438ae5194bba7cad22af5e350c5a288529cbcdb 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java
|
||||||
|
@@ -164,7 +164,7 @@ public class Dolphin extends WaterAnimal {
|
||||||
|
protected void registerGoals() {
|
||||||
|
this.goalSelector.addGoal(0, new BreathAirGoal(this));
|
||||||
|
this.goalSelector.addGoal(0, new TryFindWaterGoal(this));
|
||||||
|
- this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this));
|
||||||
|
+ if (!this.level().kaiijuConfig.disableDolphinSwimToTreasure) this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this)); // Kaiiju
|
||||||
|
this.goalSelector.addGoal(2, new Dolphin.DolphinSwimWithPlayerGoal(this, 4.0D));
|
||||||
|
this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 1.0D, 10));
|
||||||
|
this.goalSelector.addGoal(4, new RandomLookAroundGoal(this));
|
||||||
18
patches/server/0034-Unsupported-configuration.patch
Normal file
18
patches/server/0034-Unsupported-configuration.patch
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kugge <sofiane.djerbi38@gmail.com>
|
||||||
|
Date: Mon, 28 Aug 2023 16:30:36 +0200
|
||||||
|
Subject: [PATCH] Unsupported configuration
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index 2f3827441987528d79d9268002c7a7671faff429..b0515b073f30f6b3417b28b7fb2242e9ca309354 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -227,4 +227,7 @@ public class KaiijuConfig {
|
||||||
|
serverModName = getString("gameplay.server-mod-name", serverModName);
|
||||||
|
sharedRandomForPlayers = getBoolean("gameplay.shared-random-for-players", sharedRandomForPlayers);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ private static void unsupportedSettings() {
|
||||||
|
+ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Thu, 22 Jun 2023 00:55:17 +0200
|
||||||
|
Subject: [PATCH] Option to disable ensure tick thread checks
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index b0515b073f30f6b3417b28b7fb2242e9ca309354..2f5520f66da082dc1bc1f17ef3d7ed75bcf436fd 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -228,6 +228,9 @@ public class KaiijuConfig {
|
||||||
|
sharedRandomForPlayers = getBoolean("gameplay.shared-random-for-players", sharedRandomForPlayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public static boolean disableEnsureTickThreadChecks = false;
|
||||||
|
+
|
||||||
|
private static void unsupportedSettings() {
|
||||||
|
+ disableEnsureTickThreadChecks = getBoolean("unsupported.disable-ensure-tick-thread-checks", disableEnsureTickThreadChecks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/util/TickThread.java b/src/main/java/io/papermc/paper/util/TickThread.java
|
||||||
|
index c6b3c747d4c9792c3b690af4d45b13d2b05039ee..6da5a1e6e2ab7493d24e7f79f601499cb30e5c3c 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/util/TickThread.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/util/TickThread.java
|
||||||
|
@@ -46,6 +46,7 @@ public class TickThread extends Thread {
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static void ensureTickThread(final String reason) {
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
|
||||||
|
if (!isTickThread()) {
|
||||||
|
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||||
|
throw new IllegalStateException(reason);
|
||||||
|
@@ -53,6 +54,7 @@ public class TickThread extends Thread {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ensureTickThread(final ServerLevel world, final BlockPos pos, final String reason) {
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
|
||||||
|
if (!isTickThreadFor(world, pos)) {
|
||||||
|
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||||
|
throw new IllegalStateException(reason);
|
||||||
|
@@ -60,6 +62,7 @@ public class TickThread extends Thread {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ensureTickThread(final ServerLevel world, final ChunkPos pos, final String reason) {
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
|
||||||
|
if (!isTickThreadFor(world, pos)) {
|
||||||
|
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||||
|
throw new IllegalStateException(reason);
|
||||||
|
@@ -67,6 +70,7 @@ public class TickThread extends Thread {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ensureTickThread(final ServerLevel world, final int chunkX, final int chunkZ, final String reason) {
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
|
||||||
|
if (!isTickThreadFor(world, chunkX, chunkZ)) {
|
||||||
|
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||||
|
throw new IllegalStateException(reason);
|
||||||
|
@@ -74,6 +78,7 @@ public class TickThread extends Thread {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ensureTickThread(final Entity entity, final String reason) {
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
|
||||||
|
if (!isTickThreadFor(entity)) {
|
||||||
|
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||||
|
throw new IllegalStateException(reason);
|
||||||
|
@@ -81,6 +86,7 @@ public class TickThread extends Thread {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ensureTickThread(final ServerLevel world, final AABB aabb, final String reason) {
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
|
||||||
|
if (!isTickThreadFor(world, aabb)) {
|
||||||
|
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||||
|
throw new IllegalStateException(reason);
|
||||||
|
@@ -88,6 +94,7 @@ public class TickThread extends Thread {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ensureTickThread(final ServerLevel world, final double blockX, final double blockZ, final String reason) {
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
|
||||||
|
if (!isTickThreadFor(world, blockX, blockZ)) {
|
||||||
|
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||||
|
throw new IllegalStateException(reason);
|
||||||
34
patches/server/0036-Skip-event-if-no-listeners.patch
Normal file
34
patches/server/0036-Skip-event-if-no-listeners.patch
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
|
||||||
|
Date: Sat, 8 Jul 2023 01:31:10 +0300
|
||||||
|
Subject: [PATCH] Skip event if no listeners
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||||
|
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..d0f6d4e6ab3a7a4bd6cb8e27c90c7c7300f204a5 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||||
|
@@ -36,14 +36,21 @@ class PaperEventManager {
|
||||||
|
|
||||||
|
// SimplePluginManager
|
||||||
|
public void callEvent(@NotNull Event event) {
|
||||||
|
+ // Kaiiju start - Skip event of no listeners
|
||||||
|
+ HandlerList handlers = event.getHandlers();
|
||||||
|
+ RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||||
|
+ if (listeners.length == 0) return;
|
||||||
|
+ // Kaiiju end
|
||||||
|
if (event.isAsynchronous() && this.server.isPrimaryThread()) {
|
||||||
|
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||||
|
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
|
||||||
|
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||||
|
}
|
||||||
|
|
||||||
|
- HandlerList handlers = event.getHandlers();
|
||||||
|
- RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||||
|
+ // Kaiiju start - Moved up
|
||||||
|
+ //HandlerList handlers = event.getHandlers();
|
||||||
|
+ //RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||||
|
+ // Kaiiju end
|
||||||
|
|
||||||
|
for (RegisteredListener registration : listeners) {
|
||||||
|
if (!registration.getPlugin().isEnabled()) {
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sat, 8 Jul 2023 03:31:04 +0300
|
||||||
|
Subject: [PATCH] Teleport async if we cannot move entity off-main
|
||||||
|
|
||||||
|
Entities with huge velocity (100k+ velocity anarchy travel exploit) might disappear / crash the server because they travel a region each tick.
|
||||||
|
TODO: Entities with huge velocity still throw stacktraces because they are ticked in "null" regions.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
index e2fb7d7a7b3126d386b46442c115085d1974ac4e..44f5540a6a5733cf6f10f6b04fc9611ac4e53685 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
||||||
|
@@ -169,6 +169,7 @@ public class KaiijuWorldConfig {
|
||||||
|
public boolean fixTripWireStateInconsistency = true;
|
||||||
|
public boolean safeTeleporting = true;
|
||||||
|
public boolean sandDuplication = false;
|
||||||
|
+ public boolean teleportAsyncOnHighVelocity = false;
|
||||||
|
|
||||||
|
private void gameplaySettings() {
|
||||||
|
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
|
||||||
|
@@ -176,5 +177,6 @@ public class KaiijuWorldConfig {
|
||||||
|
fixTripWireStateInconsistency = getBoolean("gameplay.fix-tripwire-state-inconsistency", fixTripWireStateInconsistency);
|
||||||
|
safeTeleporting = getBoolean("gameplay.safe-teleportation", safeTeleporting);
|
||||||
|
sandDuplication = getBoolean("gameplay.sand-duplication", sandDuplication);
|
||||||
|
+ teleportAsyncOnHighVelocity = getBoolean("gameplay.teleport-async-on-high-velocity", teleportAsyncOnHighVelocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
index 3dc840bf74e12a9e757a2adaa1d0b22d68ac3d26..2d87c5f7c3d63a274fc3f104ee6d29849754c485 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -1115,7 +1115,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ try { // Kaiiju - Teleport async if we cannot move entity off-main
|
||||||
|
this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z);
|
||||||
|
+ // Kaiiju start - Teleport async if we cannot move entity off-main
|
||||||
|
+ } catch (IllegalStateException e) {
|
||||||
|
+ if (this.level().kaiijuConfig.teleportAsyncOnHighVelocity)
|
||||||
|
+ this.teleportAsync((ServerLevel) this.level(), this.position().add(vec3d1),
|
||||||
|
+ this.getYRot(), this.getXRot(),
|
||||||
|
+ null, PlayerTeleportEvent.TeleportCause.UNKNOWN,
|
||||||
|
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS,
|
||||||
|
+ null
|
||||||
|
+ );
|
||||||
|
+ else LOGGER.error("High velocity entity caused off-main setPos: ", e);
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
}
|
||||||
|
|
||||||
|
this.level().getProfiler().pop();
|
||||||
|
@@ -3940,13 +3953,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
// check for same region
|
||||||
|
if (destination == this.level()) {
|
||||||
|
Vec3 currPos = this.position();
|
||||||
|
- if (
|
||||||
|
- destination.regioniser.getRegionAtUnsynchronised(
|
||||||
|
- io.papermc.paper.util.CoordinateUtils.getChunkX(currPos), io.papermc.paper.util.CoordinateUtils.getChunkZ(currPos)
|
||||||
|
- ) == destination.regioniser.getRegionAtUnsynchronised(
|
||||||
|
- io.papermc.paper.util.CoordinateUtils.getChunkX(pos), io.papermc.paper.util.CoordinateUtils.getChunkZ(pos)
|
||||||
|
- )
|
||||||
|
- ) {
|
||||||
|
+ // Kaiiju start - We shouldn't teleport when regions are null
|
||||||
|
+ io.papermc.paper.threadedregions.ThreadedRegionizer.ThreadedRegion<io.papermc.paper.threadedregions.TickRegions.TickRegionData,
|
||||||
|
+ io.papermc.paper.threadedregions.TickRegions.TickRegionSectionData>
|
||||||
|
+ currRegion = destination.regioniser.getRegionAtUnsynchronised(io.papermc.paper.util.CoordinateUtils.getChunkX(currPos), io.papermc.paper.util.CoordinateUtils.getChunkZ(currPos));
|
||||||
|
+ io.papermc.paper.threadedregions.ThreadedRegionizer.ThreadedRegion<io.papermc.paper.threadedregions.TickRegions.TickRegionData,
|
||||||
|
+ io.papermc.paper.threadedregions.TickRegions.TickRegionSectionData>
|
||||||
|
+ destRegion = destination.regioniser.getRegionAtUnsynchronised(io.papermc.paper.util.CoordinateUtils.getChunkX(pos), io.papermc.paper.util.CoordinateUtils.getChunkZ(pos));
|
||||||
|
+ if (currRegion == destRegion && currRegion != null) {
|
||||||
|
+ // Kaiiju end
|
||||||
|
EntityTreeNode passengerTree = this.detachPassengers();
|
||||||
|
// Note: The client does not accept position updates for controlled entities. So, we must
|
||||||
|
// perform a lot of tracker updates here to make it all work out.
|
||||||
19
patches/server/0038-Add-back-worldborder-command.patch
Normal file
19
patches/server/0038-Add-back-worldborder-command.patch
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 9 Jul 2023 19:17:40 +0300
|
||||||
|
Subject: [PATCH] Add back worldborder command
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
|
index 4f6bd2d88219ac82c4d08c35231e5d3314f87110..21e2a55c3c9023718f51fdb2d3a321eceb2aa7ca 100644
|
||||||
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||||
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
|
@@ -202,7 +202,7 @@ public class Commands {
|
||||||
|
TitleCommand.register(this.dispatcher);
|
||||||
|
//TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||||
|
WeatherCommand.register(this.dispatcher);
|
||||||
|
- //WorldBorderCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||||
|
+ WorldBorderCommand.register(this.dispatcher); // Folia - region threading - TODO later // Kaiiju
|
||||||
|
if (JvmProfiler.INSTANCE.isAvailable()) {
|
||||||
|
JfrCommand.register(this.dispatcher);
|
||||||
|
}
|
||||||
19
patches/server/0039-Add-back-data-command.patch
Normal file
19
patches/server/0039-Add-back-data-command.patch
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Sun, 9 Jul 2023 19:18:42 +0300
|
||||||
|
Subject: [PATCH] Add back data command
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
|
index 21e2a55c3c9023718f51fdb2d3a321eceb2aa7ca..034c64df1fd1f58a01535183753f94899c50df2b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||||
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
|
@@ -150,7 +150,7 @@ public class Commands {
|
||||||
|
ClearInventoryCommands.register(this.dispatcher, commandRegistryAccess);
|
||||||
|
//CloneCommands.register(this.dispatcher, commandRegistryAccess); // Folia - region threading - TODO
|
||||||
|
DamageCommand.register(this.dispatcher, commandRegistryAccess);
|
||||||
|
- //DataCommands.register(this.dispatcher); // Folia - region threading - TODO
|
||||||
|
+ DataCommands.register(this.dispatcher); // Folia - region threading - TODO // Kaiiju
|
||||||
|
//DataPackCommand.register(this.dispatcher); // Folia - region threading - TODO
|
||||||
|
//DebugCommand.register(this.dispatcher); // Folia - region threading - TODO
|
||||||
|
DefaultGameModeCommands.register(this.dispatcher);
|
||||||
1314
patches/server/0040-Async-path-processing.patch
Normal file
1314
patches/server/0040-Async-path-processing.patch
Normal file
File diff suppressed because it is too large
Load Diff
50
patches/server/0041-Global-event-synchronization.patch
Normal file
50
patches/server/0041-Global-event-synchronization.patch
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Xymb <xymb@endcrystal.me>
|
||||||
|
Date: Mon, 28 Aug 2023 16:57:55 +0200
|
||||||
|
Subject: [PATCH] Global event synchronization
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
index 15cdfc9bf0e4a12f1f3e9e8c224f7a5bacd9bfc7..e8c4d6529a47ea18ec3ce1a95ae057ee82a20370 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
|
@@ -244,8 +244,10 @@ public class KaiijuConfig {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean disableEnsureTickThreadChecks = false;
|
||||||
|
+ public static boolean globalEventSynchronization = false;
|
||||||
|
|
||||||
|
private static void unsupportedSettings() {
|
||||||
|
disableEnsureTickThreadChecks = getBoolean("unsupported.disable-ensure-tick-thread-checks", disableEnsureTickThreadChecks);
|
||||||
|
+ globalEventSynchronization = getBoolean("unsupported.global-event-synchronization", globalEventSynchronization);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/lock/GlobalPluginSynchronizer.java b/src/main/java/dev/kaiijumc/kaiiju/lock/GlobalPluginSynchronizer.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..406b241c8d4998b9977a43b8c1b628c7a27a927d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/lock/GlobalPluginSynchronizer.java
|
||||||
|
@@ -0,0 +1,5 @@
|
||||||
|
+package dev.kaiijumc.kaiiju.lock;
|
||||||
|
+
|
||||||
|
+public class GlobalPluginSynchronizer {
|
||||||
|
+ public static final Object lock = new Object();
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||||
|
index d0f6d4e6ab3a7a4bd6cb8e27c90c7c7300f204a5..03b8f704de1e9a798391297d3daf3c49bf599a56 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||||
|
@@ -58,6 +58,13 @@ class PaperEventManager {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
+ // Kaiiju start - Global Event Synchronization
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.globalEventSynchronization) {
|
||||||
|
+ synchronized (dev.kaiijumc.kaiiju.lock.GlobalPluginSynchronizer.lock) {
|
||||||
|
+ registration.callEvent(event);
|
||||||
|
+ }
|
||||||
|
+ } else
|
||||||
|
+ // Kaiiju end
|
||||||
|
registration.callEvent(event);
|
||||||
|
} catch (AuthorNagException ex) {
|
||||||
|
Plugin plugin = registration.getPlugin();
|
||||||
101
patches/todo/0012-Static-Distance-WIP.patch
Normal file
101
patches/todo/0012-Static-Distance-WIP.patch
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
||||||
|
Date: Wed, 19 Apr 2023 02:37:04 +0300
|
||||||
|
Subject: [PATCH] Static Distance WIP
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||||
|
index e77972c4c264100ffdd824bfa2dac58dbbc6d678..cddacd6d5bbe97641bd23f5c067012907d9c5c01 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
|
||||||
|
@@ -75,6 +75,17 @@ public final class PlayerChunkLoader {
|
||||||
|
return data.getTargetSendViewDistance();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
+ public static int getStaticDistance(final ServerPlayer player) {
|
||||||
|
+ final ServerLevel level = (ServerLevel)player.level;
|
||||||
|
+ final PlayerLoaderData data = level.chunkSource.chunkMap.playerChunkManager.getData(player);
|
||||||
|
+ if (data == null) {
|
||||||
|
+ return level.chunkSource.chunkMap.playerChunkManager.getTargetStaticDistance();
|
||||||
|
+ }
|
||||||
|
+ return data.getTargetSendViewDistance();
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
protected final ChunkMap chunkMap;
|
||||||
|
protected final Reference2ObjectLinkedOpenHashMap<ServerPlayer, PlayerLoaderData> playerMap = new Reference2ObjectLinkedOpenHashMap<>(512, 0.7f);
|
||||||
|
protected final ReferenceLinkedOpenHashSet<PlayerLoaderData> chunkSendQueue = new ReferenceLinkedOpenHashSet<>(512, 0.7f);
|
||||||
|
@@ -132,6 +143,12 @@ public final class PlayerChunkLoader {
|
||||||
|
|
||||||
|
// no throttling is applied below this VD for loading
|
||||||
|
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
+ public final PlayerAreaMap staticMap;
|
||||||
|
+ protected int rawStaticDistance = -1;
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* The chunks to be sent to players, provided they're send-ready. Send-ready means the chunk and its 1 radius neighbours are loaded.
|
||||||
|
*/
|
||||||
|
@@ -190,6 +207,12 @@ public final class PlayerChunkLoader {
|
||||||
|
return this.rawSendDistance == -1 ? this.getLoadDistance() : this.rawSendDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
+ public int getTargetStaticDistance() {
|
||||||
|
+ return this.rawStaticDistance == -1 ? this.getStaticDistance() : this.rawStaticDistance;
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
public void setTargetSendDistance(final int distance) {
|
||||||
|
this.setSendDistance(distance);
|
||||||
|
}
|
||||||
|
@@ -231,6 +254,16 @@ public final class PlayerChunkLoader {
|
||||||
|
this.rawTickDistance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
+ public void setStaticDistance(final int distance) {
|
||||||
|
+ this.rawStaticDistance = distance;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int getStaticDistance() {
|
||||||
|
+ return this.rawStaticDistance;
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
Players have 3 different types of view distance:
|
||||||
|
1. Sending view distance
|
||||||
|
@@ -256,7 +289,13 @@ public final class PlayerChunkLoader {
|
||||||
|
|
||||||
|
public PlayerChunkLoader(final ChunkMap chunkMap, final PooledLinkedHashSets<ServerPlayer> pooledHashSets) {
|
||||||
|
this.chunkMap = chunkMap;
|
||||||
|
+ // Kaiiju start - Static distance
|
||||||
|
this.broadcastMap = new PlayerAreaMap(pooledHashSets,
|
||||||
|
+ null,
|
||||||
|
+ (ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
|
||||||
|
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newState) -> {});
|
||||||
|
+ // Kaiiju end
|
||||||
|
+ this.staticMap = new PlayerAreaMap(pooledHashSets,
|
||||||
|
null,
|
||||||
|
(ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
|
||||||
|
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newState) -> {
|
||||||
|
@@ -807,6 +846,7 @@ public final class PlayerChunkLoader {
|
||||||
|
protected int sendViewDistance = -1;
|
||||||
|
protected int loadViewDistance = -1;
|
||||||
|
protected int tickViewDistance = -1;
|
||||||
|
+ protected int staticViewDistance = -1; // Kaiiju
|
||||||
|
|
||||||
|
protected long nextChunkSendTarget;
|
||||||
|
|
||||||
|
@@ -932,6 +972,7 @@ public final class PlayerChunkLoader {
|
||||||
|
this.loader.loadMap.remove(this.player);
|
||||||
|
this.loader.loadTicketCleanup.remove(this.player);
|
||||||
|
this.loader.tickMap.remove(this.player);
|
||||||
|
+ this.loader.staticMap.remove(this.player); // Kaiiju
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getClientViewDistance() {
|
||||||
Reference in New Issue
Block a user