Compare commits
19 Commits
build-232
...
feat/async
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7278888017 | ||
|
|
d1a9c55403 | ||
|
|
29fabdd8f3 | ||
|
|
ae1f11a394 | ||
|
|
b45f3843c2 | ||
|
|
8e31fc9945 | ||
|
|
ccd629843c | ||
|
|
ada5265608 | ||
|
|
f508c9cd84 | ||
|
|
e6c765ef71 | ||
|
|
cb1b2a78ac | ||
|
|
ad43ef6000 | ||
|
|
eb571af123 | ||
|
|
9925aa59c7 | ||
|
|
2dc38b4f88 | ||
|
|
4401555131 | ||
|
|
6da53043d4 | ||
|
|
ea1493dd8f | ||
|
|
e18e9091fb |
51
README.md
51
README.md
@@ -11,14 +11,13 @@
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
### Notable
|
### Primary
|
||||||
- **Xymb Linear Format**: A Region file format that reduces disk space usage by about 50%.
|
- **Xymb Linear Format**: Saves about 50% of disk space in OW/Nether and 95% in The End.
|
||||||
- **Async Pathfinding**: Petal async pathfinding fixed & reworked.
|
- **Auto update**: Automatic upstream updates.
|
||||||
- **Technical Minecraft**: Enable Vanilla exploits such as sand duping, RNG manipulation...
|
|
||||||
|
|
||||||
### Other
|
### Notable
|
||||||
- **Small optimizations**: Increase server efficiency by disabling unnecessary features.
|
- **Entity throttling & removal**: Tweak entity tick frequency & max entity per region.
|
||||||
- **Commands**: Restore few commands that were previously removed by Folia.
|
- **Technical Minecraft**: Enable Vanilla exploits such as sand duping, RNG manipulation...
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
@@ -26,31 +25,16 @@
|
|||||||
network:
|
network:
|
||||||
send-null-entity-packets: true
|
send-null-entity-packets: true
|
||||||
alternate-keepalive: false
|
alternate-keepalive: false
|
||||||
kick-player-on-bad-packet: true
|
|
||||||
gameplay:
|
|
||||||
server-mod-name: Kaiiju
|
|
||||||
shared-random-for-players: true
|
|
||||||
region-format:
|
|
||||||
debug: false
|
|
||||||
optimization:
|
optimization:
|
||||||
disable-vanish-api: false
|
disable-vanish-api: false
|
||||||
disable-player-stats: false
|
disable-player-stats: false
|
||||||
disable-arm-swing-event: false
|
disable-arm-swing-event: false
|
||||||
disable-ensure-tick-thread-checks: false
|
disable-ensure-tick-thread-checks: false
|
||||||
async-path-processing:
|
gameplay:
|
||||||
enable: false
|
server-mod-name: Kaiiju
|
||||||
max-threads: 0
|
shared-random-for-players: true
|
||||||
keepalive: 60
|
|
||||||
queue-capacity: 4096
|
|
||||||
world-settings:
|
world-settings:
|
||||||
default:
|
default:
|
||||||
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
|
|
||||||
region-format:
|
region-format:
|
||||||
format: ANVIL
|
format: ANVIL
|
||||||
linear:
|
linear:
|
||||||
@@ -58,22 +42,25 @@ world-settings:
|
|||||||
crash-on-broken-symlink: true
|
crash-on-broken-symlink: true
|
||||||
optimization:
|
optimization:
|
||||||
shulker-box-drop-contents-when-destroyed: true
|
shulker-box-drop-contents-when-destroyed: true
|
||||||
optimize-hoppers: true
|
|
||||||
tick-when-empty: true
|
|
||||||
enable-entity-throttling: false
|
enable-entity-throttling: false
|
||||||
disable-achievements: false
|
disable-achievements: false
|
||||||
disable-creatures-spawn-events: false
|
disable-creatures-spawn-events: false
|
||||||
disable-dolphin-swim-to-treasure: false
|
disable-dolphin-swim-to-treasure: false
|
||||||
|
gameplay:
|
||||||
|
fix-void-trading: true
|
||||||
|
optimize-hoppers: true
|
||||||
|
tick-when-empty: true
|
||||||
|
break-redstone-on-top-of-trap-doors-early: true
|
||||||
|
fix-tripwire-state-inconsistency: true
|
||||||
|
safe-teleportation: true
|
||||||
|
sand-duplication: false
|
||||||
```
|
```
|
||||||
Documentation: [Kaiiju Wiki](https://github.com/KaiijuMC/Kaiiju/wiki/Configuration)
|
Documentation: [Kaiiju Wiki](https://github.com/KaiijuMC/Kaiiju/wiki/Configuration)
|
||||||
|
|
||||||
### Roadmap
|
### Roadmap
|
||||||
- **Stash deduplication**: Make giant dupe stashes possible and lagless.
|
- **Static view distance**: Reduce RAM usage / Region size with a "static" view distance.
|
||||||
- **Multithreaded Tracker**: Rework Petal multithreaded tracker.
|
|
||||||
|
|
||||||
## Open to contributions
|
|
||||||
- **Native world conversion**: Convert region file format at startup.
|
- **Native world conversion**: Convert region file format at startup.
|
||||||
- **Performance patch**: Any significative performance patch.
|
- **Stash deduplication**: Make giant dupe stashes possible and lagless.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ group = dev.kaiijumc.kaiiju
|
|||||||
version = 1.20.1-R0.1-SNAPSHOT
|
version = 1.20.1-R0.1-SNAPSHOT
|
||||||
mcVersion = 1.20.1
|
mcVersion = 1.20.1
|
||||||
|
|
||||||
foliaRef = 3cf16eeaf2e9c2346b9825900e5eaab376654c36
|
foliaRef = daacd4255022f3a1bf74dd3e84f751be838678ac
|
||||||
|
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|||||||
@@ -5,15 +5,18 @@ 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..f08bcc9ae1770fa847d8a5e873a554bef5485100 100644
|
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..b86c90cc3601e666998cfa12f44515f605bb53eb 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,7 @@ public class KaiijuConfig {
|
@@ -192,4 +192,10 @@ 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
|
||||||
@@ -82,7 +85,7 @@ index 0000000000000000000000000000000000000000..7164d9cd03186f0657783f83de3d6435
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
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 7e5645d9cb64ce17f60c85619f5640c8de4b1e86..bc9204d2c925437e9ff5c5d62d9faf38c2938e48 100644
|
index cc1a7c4d38874ec218f7151685ae6cc00295c2e4..06233380f7580726753de34c1fb23d6347c9ac94 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
|
||||||
@@ -893,7 +893,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -893,7 +893,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
|||||||
@@ -38,34 +38,6 @@ 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
|
||||||
@@ -140,10 +112,10 @@ index 0000000000000000000000000000000000000000..dcfbabf54b19a4c29d5c95830242c5c2
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
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..e40989889f3821bb7484fc0bae5d94b033013904
|
index 0000000000000000000000000000000000000000..b7ce89429675bde7f037793305275f4bf89d0727
|
||||||
--- /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,316 @@
|
@@ -0,0 +1,337 @@
|
||||||
+package dev.kaiijumc.kaiiju.region;
|
+package dev.kaiijumc.kaiiju.region;
|
||||||
+
|
+
|
||||||
+import com.github.luben.zstd.ZstdInputStream;
|
+import com.github.luben.zstd.ZstdInputStream;
|
||||||
@@ -166,57 +138,65 @@ index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b0
|
|||||||
+import java.util.ArrayList;
|
+import java.util.ArrayList;
|
||||||
+import java.util.Arrays;
|
+import java.util.Arrays;
|
||||||
+import java.util.List;
|
+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 implements AbstractRegionFile, AutoCloseable {
|
+public class LinearRegionFile extends Thread implements AbstractRegionFile {
|
||||||
+ private static final long SUPERBLOCK = -4323716122432332390L;
|
+ private static final long SUPERBLOCK = -4323716122432332390L;
|
||||||
+ private static final byte VERSION = 2;
|
+ private static final byte VERSION = 2;
|
||||||
+ private static final int HEADER_SIZE = 32;
|
+ private static final int HEADER_SIZE = 32;
|
||||||
+ private static final int FOOTER_SIZE = 8;
|
+ private static final int FOOTER_SIZE = 8;
|
||||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
+ private static final List<Byte> SUPPORTED_VERSIONS = Arrays.asList((byte) 1, (byte) 2);
|
+ private static final List<Byte> SUPPORTED_VERSIONS = Arrays.asList((byte) 1, (byte) 2);
|
||||||
+ private static final LinearRegionFileFlusher linearRegionFileFlusher = new LinearRegionFileFlusher();
|
+
|
||||||
+
|
+
|
||||||
+ private final byte[][] buffer = new byte[1024][];
|
+ private final byte[][] buffer = new byte[1024][];
|
||||||
+ private final int[] bufferUncompressedSize = new int[1024];
|
+ private final int[] bufferUncompressedSize = new int[1024];
|
||||||
+
|
+
|
||||||
+ private final int[] chunkTimestamps = new int[1024];
|
+ private final int[] chunkTimestamps = new int[1024];
|
||||||
|
+ private final Object markedToSaveLock = new Object();
|
||||||
+ private final ChunkStatus[] statuses = new ChunkStatus[1024];
|
+ private final ChunkStatus[] statuses = new ChunkStatus[1024];
|
||||||
+
|
+
|
||||||
+ private final LZ4Compressor compressor;
|
+ private final LZ4Compressor compressor;
|
||||||
+ private final LZ4FastDecompressor decompressor;
|
+ private final LZ4FastDecompressor decompressor;
|
||||||
+
|
+
|
||||||
|
+ private boolean markedToSave = false;
|
||||||
|
+ private boolean close = false;
|
||||||
|
+
|
||||||
+ 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 Path getRegionFile() {
|
||||||
+ public boolean closed = false;
|
+ return this.regionFile;
|
||||||
+ public Path path;
|
+ }
|
||||||
+
|
+
|
||||||
|
+ public ReentrantLock getFileLock() {
|
||||||
|
+ return this.fileLock;
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
||||||
+ this.path = file;
|
+ this.regionFile = file;
|
||||||
+ this.compressionLevel = compression;
|
+ this.compressionLevel = compression;
|
||||||
|
+
|
||||||
+ this.compressor = LZ4Factory.fastestInstance().fastCompressor();
|
+ this.compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||||
+ this.decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
+ this.decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||||
+
|
+
|
||||||
+ File regionFile = new File(this.path.toString());
|
+ File regionFile = new File(this.regionFile.toString());
|
||||||
+
|
+
|
||||||
+ Arrays.fill(this.bufferUncompressedSize, 0);
|
+ Arrays.fill(this.bufferUncompressedSize, 0);
|
||||||
+
|
+
|
||||||
+ if (!regionFile.canRead()) return;
|
+ if(regionFile.canRead()) {
|
||||||
+
|
+ FileInputStream fileStream = new FileInputStream(regionFile);
|
||||||
+ try (FileInputStream fileStream = new FileInputStream(regionFile);
|
+ DataInputStream rawDataStream = new DataInputStream(fileStream);
|
||||||
+ DataInputStream rawDataStream = new DataInputStream(fileStream)) {
|
|
||||||
+
|
+
|
||||||
+ long superBlock = rawDataStream.readLong();
|
+ long superBlock = rawDataStream.readLong();
|
||||||
+ if (superBlock != SUPERBLOCK)
|
+ if (superBlock != SUPERBLOCK)
|
||||||
+ throw new RuntimeException("Invalid superblock: " + superBlock + " in " + file);
|
+ throw new RuntimeException("Invalid superblock: " + superBlock + " file " + file);
|
||||||
+
|
+
|
||||||
+ byte version = rawDataStream.readByte();
|
+ byte version = rawDataStream.readByte();
|
||||||
+ if (!SUPPORTED_VERSIONS.contains(version))
|
+ if (!SUPPORTED_VERSIONS.contains(version))
|
||||||
+ throw new RuntimeException("Invalid version: " + version + " in " + file);
|
+ throw new RuntimeException("Invalid version: " + version + " file " + file);
|
||||||
+
|
+
|
||||||
+ // Skip newestTimestamp (Long) + Compression level (Byte) + Chunk count (Short): Unused.
|
+ // Skip newestTimestamp (Long) + Compression level (Byte) + Chunk count (Short): Unused.
|
||||||
+ rawDataStream.skipBytes(11);
|
+ rawDataStream.skipBytes(11);
|
||||||
@@ -224,7 +204,7 @@ index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b0
|
|||||||
+ int dataCount = rawDataStream.readInt();
|
+ int dataCount = rawDataStream.readInt();
|
||||||
+ long fileLength = file.toFile().length();
|
+ long fileLength = file.toFile().length();
|
||||||
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE)
|
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE)
|
||||||
+ throw new IOException("Invalid file length: " + this.path + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
+ throw new IOException("Invalid file length: " + this.regionFile + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||||
+
|
+
|
||||||
+ rawDataStream.skipBytes(8); // Skip data hash (Long): Unused.
|
+ rawDataStream.skipBytes(8); // Skip data hash (Long): Unused.
|
||||||
+
|
+
|
||||||
@@ -233,123 +213,132 @@ index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b0
|
|||||||
+
|
+
|
||||||
+ superBlock = rawDataStream.readLong();
|
+ superBlock = rawDataStream.readLong();
|
||||||
+ if (superBlock != SUPERBLOCK)
|
+ if (superBlock != SUPERBLOCK)
|
||||||
+ throw new IOException("Footer superblock invalid " + this.path);
|
+ throw new IOException("Footer superblock invalid " + this.regionFile);
|
||||||
+
|
+
|
||||||
+ try (DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)))) {
|
+ DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)));
|
||||||
+
|
+
|
||||||
+ int[] starts = new int[1024];
|
+ int[] starts = new int[1024];
|
||||||
+ for (int i = 0; i < 1024; i++) {
|
+ for(int i = 0; i < 1024; i++) {
|
||||||
+ starts[i] = dataStream.readInt();
|
+ starts[i] = dataStream.readInt();
|
||||||
+ dataStream.skipBytes(4); // Skip timestamps (Int): Unused.
|
+ dataStream.skipBytes(4); // Skip timestamps (Int): Unused.
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ for (int i = 0; i < 1024; i++) {
|
+ for(int i = 0; i < 1024; i++) {
|
||||||
+ if (starts[i] > 0) {
|
+ if(starts[i] > 0) {
|
||||||
+ int size = starts[i];
|
+ int size = starts[i];
|
||||||
+ byte[] b = new byte[size];
|
+ byte[] b = new byte[size];
|
||||||
+ dataStream.readFully(b, 0, size);
|
+ dataStream.readFully(b, 0, size);
|
||||||
+
|
+
|
||||||
+ int maxCompressedLength = this.compressor.maxCompressedLength(size);
|
+ int maxCompressedLength = this.compressor.maxCompressedLength(size);
|
||||||
+ byte[] compressed = new byte[maxCompressedLength];
|
+ byte[] compressed = new byte[maxCompressedLength];
|
||||||
+ int compressedLength = this.compressor.compress(b, 0, size, compressed, 0, maxCompressedLength);
|
+ int compressedLength = this.compressor.compress(b, 0, size, compressed, 0, maxCompressedLength);
|
||||||
+ b = new byte[compressedLength];
|
+ b = new byte[compressedLength];
|
||||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||||
+
|
+
|
||||||
+ this.buffer[i] = b;
|
+ this.buffer[i] = b;
|
||||||
+ this.bufferUncompressedSize[i] = size;
|
+ this.bufferUncompressedSize[i] = size;
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+ this.start();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public Path getRegionFile() {
|
+ private synchronized void markToSave() {
|
||||||
+ return this.path;
|
+ synchronized(markedToSaveLock) {
|
||||||
+ }
|
+ markedToSave = true;
|
||||||
+
|
|
||||||
+ public ReentrantLock getFileLock() {
|
|
||||||
+ return this.fileLock;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public void flush() throws IOException {
|
|
||||||
+ if (isMarkedToSave()) flushWrapper(); // sync
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private void markToSave() {
|
|
||||||
+ linearRegionFileFlusher.scheduleSave(this);
|
|
||||||
+ markedToSave.set(true);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public boolean isMarkedToSave() {
|
|
||||||
+ return markedToSave.getAndSet(false);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public void flushWrapper() {
|
|
||||||
+ try {
|
|
||||||
+ save();
|
|
||||||
+ } catch (IOException e) {
|
|
||||||
+ LOGGER.error("Failed to flush region file " + path.toAbsolutePath(), e);
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public boolean doesChunkExist(ChunkPos pos) throws Exception {
|
+ private synchronized boolean isMarkedToSave() {
|
||||||
|
+ synchronized(markedToSaveLock) {
|
||||||
|
+ if(markedToSave) {
|
||||||
|
+ markedToSave = false;
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void run() {
|
||||||
|
+ try {
|
||||||
|
+ while(true) {
|
||||||
|
+ if(markedToSave) {
|
||||||
|
+ try {
|
||||||
|
+ 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 {
|
||||||
+ throw new Exception("doesChunkExist is a stub");
|
+ throw new Exception("doesChunkExist is a stub");
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private synchronized void save() throws IOException {
|
+ public synchronized void flush() throws IOException {
|
||||||
|
+ if(!isMarkedToSave()) return;
|
||||||
|
+
|
||||||
+ long timestamp = getTimestamp();
|
+ long timestamp = getTimestamp();
|
||||||
+ short chunkCount = 0;
|
+ short chunkCount = 0;
|
||||||
+
|
+
|
||||||
+ File tempFile = new File(path.toString() + ".tmp");
|
+ File tempFile = new File(regionFile.toString() + ".tmp");
|
||||||
|
+ FileOutputStream fileStream = new FileOutputStream(tempFile);
|
||||||
+
|
+
|
||||||
+ try (FileOutputStream fileStream = new FileOutputStream(tempFile);
|
+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream();
|
||||||
+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream();
|
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel);
|
||||||
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel);
|
+ zstdStream.setChecksum(true);
|
||||||
+ 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);
|
||||||
+
|
+
|
||||||
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
|
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
|
||||||
+ for (int i = 0; i < 1024; i++) {
|
+ for(int i = 0; i < 1024; i++) {
|
||||||
+ if (this.bufferUncompressedSize[i] != 0) {
|
+ if(this.bufferUncompressedSize[i] != 0) {
|
||||||
+ chunkCount += 1;
|
+ chunkCount += 1;
|
||||||
+ byte[] content = new byte[bufferUncompressedSize[i]];
|
+ byte[] content = new byte[bufferUncompressedSize[i]];
|
||||||
+ this.decompressor.decompress(buffer[i], 0, content, 0, bufferUncompressedSize[i]);
|
+ this.decompressor.decompress(buffer[i], 0, content, 0, bufferUncompressedSize[i]);
|
||||||
+
|
+
|
||||||
+ byteBuffers.add(content);
|
+ byteBuffers.add(content);
|
||||||
+ } else byteBuffers.add(null);
|
+ } else byteBuffers.add(null);
|
||||||
+ }
|
|
||||||
+ for (int i = 0; i < 1024; i++) {
|
|
||||||
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]); // Write uncompressed size
|
|
||||||
+ 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();
|
|
||||||
+
|
|
||||||
+ 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
|
|
||||||
+ }
|
+ }
|
||||||
+ Files.move(tempFile.toPath(), this.path, StandardCopyOption.REPLACE_EXISTING);
|
+ for(int i = 0; i < 1024; i++) {
|
||||||
+ }
|
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]); // Write uncompressed size
|
||||||
|
+ zstdDataStream.writeInt(this.chunkTimestamps[i]); // Write timestamp
|
||||||
|
+ }
|
||||||
|
+ for(int i = 0; i < 1024; 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;
|
||||||
@@ -371,7 +360,7 @@ index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b0
|
|||||||
+ this.chunkTimestamps[index] = getTimestamp();
|
+ 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.path);
|
+ LOGGER.error("Chunk write IOException " + e + " " + this.regionFile);
|
||||||
+ }
|
+ }
|
||||||
+ markToSave();
|
+ markToSave();
|
||||||
+ }
|
+ }
|
||||||
@@ -381,6 +370,7 @@ index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b0
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ 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) {
|
||||||
@@ -433,9 +423,12 @@ index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b0
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public void close() throws IOException {
|
+ public void close() throws IOException {
|
||||||
+ if (closed) return;
|
+ close = true;
|
||||||
+ closed = true;
|
+ try {
|
||||||
+ flush(); // sync
|
+ flush();
|
||||||
|
+ } 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) {
|
||||||
@@ -453,64 +446,13 @@ index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b0
|
|||||||
+ 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.path);
|
+ throw new IOException("getOversizedData is a stub " + this.regionFile);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ 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
|
||||||
@@ -645,21 +587,21 @@ index 25fe439c8d1e88a86e85ac9a4761425d98ee6c4f..c4d28d887b4cc71dc713b1e3f46bc80f
|
|||||||
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 cf8f93734121e5c1959959f0ba13ee4e6db31959..e6e985e8e2c7cccb2c3395ae3fbc30072e1d48f0 100644
|
index 042ca6b3faae5249210567f2c26dff404974e1ff..7099a44a2322ab390c21e74668c8657dcc9e5e87 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
|
||||||
@@ -453,8 +453,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -426,8 +426,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
|
||||||
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(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
+ public EntityRegionFileStorage(String 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 {
|
||||||
@@ -693,7 +693,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -666,7 +666,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();
|
||||||
@@ -812,7 +754,7 @@ 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 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655a8c77ce1 100644
|
index 81554c321a78258ff78da3801f00d0fb90b9e113..b35a6a7daf768af3bc453fe18deec823f4b63a3a 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 {
|
@@ -22,9 +22,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
@@ -894,7 +836,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
return regionfile;
|
return regionfile;
|
||||||
@@ -126,28 +134,45 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -126,28 +134,49 @@ 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
|
||||||
@@ -932,6 +874,10 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
+ // Kaiiju end
|
+ // Kaiiju end
|
||||||
this.createRegionFile(regionPos);
|
this.createRegionFile(regionPos);
|
||||||
}
|
}
|
||||||
|
+ // Kaiiju start - Polyglot
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.regionFormatDebug)
|
||||||
|
+ org.bukkit.Bukkit.getLogger().info("Opening file " + path1 + " with format " + this.format + " (existingOnly = " + existingOnly + ")");
|
||||||
|
+ // Kaiiju end
|
||||||
+
|
+
|
||||||
// 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
|
||||||
@@ -947,7 +893,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
return regionfile1;
|
return regionfile1;
|
||||||
@@ -175,7 +200,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -175,7 +204,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -956,7 +902,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
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);
|
||||||
@@ -222,14 +247,14 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -222,14 +251,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
|
||||||
@@ -973,7 +919,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
// 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
|
||||||
@@ -239,7 +264,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -239,7 +268,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
|
|
||||||
// Paper start
|
// Paper start
|
||||||
if (regionfile.isOversized(pos.x, pos.z)) {
|
if (regionfile.isOversized(pos.x, pos.z)) {
|
||||||
@@ -982,7 +928,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
return readOversizedChunk(regionfile, pos);
|
return readOversizedChunk(regionfile, pos);
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
@@ -253,12 +278,12 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -253,12 +282,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)) {
|
||||||
@@ -998,7 +944,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,13 +317,13 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -292,13 +321,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
|
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
} finally { // Paper start
|
} finally { // Paper start
|
||||||
@@ -1014,7 +960,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
if (regionfile == null) {
|
if (regionfile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -328,7 +353,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -328,7 +357,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 {
|
||||||
@@ -1023,7 +969,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
if (nbt == null && regionfile == null) {
|
if (nbt == null && regionfile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -378,7 +403,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -378,7 +407,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
} finally { // Paper start
|
} finally { // Paper start
|
||||||
@@ -1032,7 +978,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
} // Paper end
|
} // Paper end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +412,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -387,7 +416,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||||
|
|
||||||
while (objectiterator.hasNext()) {
|
while (objectiterator.hasNext()) {
|
||||||
@@ -1041,7 +987,7 @@ index 81554c321a78258ff78da3801f00d0fb90b9e113..e91e8aef8b63ea9d94e0ecb3e4a62655
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
regionfile.close();
|
regionfile.close();
|
||||||
@@ -403,7 +428,7 @@ public class RegionFileStorage implements AutoCloseable {
|
@@ -403,7 +432,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||||
|
|
||||||
while (objectiterator.hasNext()) {
|
while (objectiterator.hasNext()) {
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ 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 b7f43cce80742aa0cd523e930772ff84946f3eef..fa829cef4033625470dfae29ddf777e6c5ab8c55 100644
|
index b86c90cc3601e666998cfa12f44515f605bb53eb..7c6d43d8a360530344ef296f4477750c8a298607 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
|
||||||
@@ -203,4 +203,7 @@ public class KaiijuConfig {
|
@@ -198,4 +198,7 @@ public class KaiijuConfig {
|
||||||
else
|
private static void regionFormatSettings() {
|
||||||
linearFlushThreads = Math.max(linearFlushThreads, 1);
|
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ private static void networkSettings() {
|
+ private static void networkSettings() {
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ Subject: [PATCH] Send null entity packets
|
|||||||
This is from Purpur. Don't 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 fa829cef4033625470dfae29ddf777e6c5ab8c55..47e23a196ae5e44600a64184b69141c00235baca 100644
|
index 7c6d43d8a360530344ef296f4477750c8a298607..ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7 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
|
||||||
@@ -203,7 +203,10 @@ public class KaiijuConfig {
|
@@ -198,7 +198,10 @@ public class KaiijuConfig {
|
||||||
else
|
private static void regionFormatSettings() {
|
||||||
linearFlushThreads = Math.max(linearFlushThreads, 1);
|
regionFormatDebug = getBoolean("region-format.debug", regionFormatDebug);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ public static boolean sendNullEntityPackets = true;
|
+ public static boolean sendNullEntityPackets = true;
|
||||||
@@ -21,7 +21,7 @@ index fa829cef4033625470dfae29ddf777e6c5ab8c55..47e23a196ae5e44600a64184b69141c0
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 81d0b2933040a451441f660f9e46199ae3b111e3..cdbc4be679d7e096c1005eaf84b74c4877479c43 100644
|
index 6670e657e08e130f7e0368f418379fd1ece00cdf..5558d87ef182f82be7877455dd027082c6a80632 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
|
||||||
@@ -201,6 +201,11 @@ public class ServerEntity {
|
@@ -201,6 +201,11 @@ public class ServerEntity {
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ Don't kick players because 1 keepalive is lost.
|
|||||||
This patch is from Purpur.
|
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 47e23a196ae5e44600a64184b69141c00235baca..95b53b50606ea0ad47f407bebbb9e2bd445c0e66 100644
|
index ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7..b42a3466f145a92608c8746fd4beb529b4a60b01 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
|
||||||
@@ -205,8 +205,10 @@ public class KaiijuConfig {
|
@@ -200,8 +200,10 @@ public class KaiijuConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean sendNullEntityPackets = true;
|
public static boolean sendNullEntityPackets = true;
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ 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 95b53b50606ea0ad47f407bebbb9e2bd445c0e66..8aab072a21b0775338b8235a84f5f675f385cf37 100644
|
index b42a3466f145a92608c8746fd4beb529b4a60b01..7b56cc1275319cf07a4a25280e0ff900bdca8afa 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
|
||||||
@@ -211,4 +211,7 @@ public class KaiijuConfig {
|
@@ -206,4 +206,7 @@ public class KaiijuConfig {
|
||||||
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
sendNullEntityPackets = getBoolean("network.send-null-entity-packets", sendNullEntityPackets);
|
||||||
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Gameplay 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 8aab072a21b0775338b8235a84f5f675f385cf37..46ae5b84ee5b87b0ed0b93e920689e44288a50d2 100644
|
index 7b56cc1275319cf07a4a25280e0ff900bdca8afa..fdc4cdbf34ed10f6523dceac7c1931d3ca4eb522 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
|
||||||
@@ -214,4 +214,7 @@ public class KaiijuConfig {
|
@@ -209,4 +209,7 @@ public class KaiijuConfig {
|
||||||
|
|
||||||
private static void optimizationSettings() {
|
private static void optimizationSettings() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ 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 46ae5b84ee5b87b0ed0b93e920689e44288a50d2..778de435ca3c13ccc2f2d86030e3529436a2d945 100644
|
index fdc4cdbf34ed10f6523dceac7c1931d3ca4eb522..e1f50adfa216320bc53b460d11666064cb58c969 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
|
||||||
@@ -215,6 +215,9 @@ public class KaiijuConfig {
|
@@ -210,6 +210,9 @@ public class KaiijuConfig {
|
||||||
private static void optimizationSettings() {
|
private static void optimizationSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ index 46ae5b84ee5b87b0ed0b93e920689e44288a50d2..778de435ca3c13ccc2f2d86030e35294
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 bc9204d2c925437e9ff5c5d62d9faf38c2938e48..5168d16b7e9ed08bdedd0e386f9671a63b6859be 100644
|
index 06233380f7580726753de34c1fb23d6347c9ac94..1b3f895b51b634ee9cf69cdbbfd7a1e600de16f0 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
|
||||||
@@ -1812,7 +1812,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1812,7 +1812,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ index abf5e2a06af9853b58ac9107cd6e9787c4185c66..389c68c0becd2f69dc1004d0b383f1a8
|
|||||||
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 c4d28d887b4cc71dc713b1e3f46bc80f4484a95d..f50507ab85282d261985ce9b186581f5a7a50f79 100644
|
index 61c6bc2859235874aefac71e9e55162f0a89f29f..24bd63c596c9f61f1e89ec5b001b7cb7a29a09ff 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
|
||||||
@@ -269,7 +269,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -269,7 +269,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
@@ -64,21 +64,21 @@ index c4d28d887b4cc71dc713b1e3f46bc80f4484a95d..f50507ab85282d261985ce9b186581f5
|
|||||||
// 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 e6e985e8e2c7cccb2c3395ae3fbc30072e1d48f0..ad896c8a3060f5c8d85a8b5707317de646bf9cae 100644
|
index 4774d3f357d62b0818b4713f8085d05be09eaa5c..1bbd8b475cdc57fb15ca05ffe122220a5539da10 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
|
||||||
@@ -453,8 +453,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -426,8 +426,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
|
||||||
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(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
- public EntityRegionFileStorage(String format, int linearCompression, Path directory, boolean dsync) { // Kaiiju
|
||||||
- super(format, linearCompression, directory, dsync); // Kaiiju
|
- super(format, linearCompression, directory, dsync); // Kaiiju
|
||||||
+ public EntityRegionFileStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat 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 {
|
||||||
@@ -693,7 +693,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -666,7 +666,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();
|
||||||
@@ -135,7 +135,7 @@ index 1d880f27dd147da683fc30ed6f1bfa43ecdb7d93..41598adf6d49a44bcaadfff379722146
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 e91e8aef8b63ea9d94e0ecb3e4a62655a8c77ce1..bbc6a0c70cbafbfa411ab418e4fec11ad101ae91 100644
|
index b35a6a7daf768af3bc453fe18deec823f4b63a3a..8409293b3f329715d6dff3d455c6a484d5b133ee 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
@@ -20,6 +20,7 @@ import net.minecraft.world.level.ChunkPos;
|
@@ -20,6 +20,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||||
@@ -209,7 +209,7 @@ index e91e8aef8b63ea9d94e0ecb3e4a62655a8c77ce1..bbc6a0c70cbafbfa411ab418e4fec11a
|
|||||||
+ guardAgainstBrokenSymlinks(path1); // Kaiiju - Crash on broken symlink
|
+ guardAgainstBrokenSymlinks(path1); // Kaiiju - Crash on broken symlink
|
||||||
this.createRegionFile(regionPos);
|
this.createRegionFile(regionPos);
|
||||||
}
|
}
|
||||||
|
// Kaiiju start - Polyglot
|
||||||
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 9394d191c56aab78e63fd3f283efedd69384e323..dcfe4a285cc5865be3b0c1b8104b722895135dd0 100644
|
index 9394d191c56aab78e63fd3f283efedd69384e323..dcfe4a285cc5865be3b0c1b8104b722895135dd0 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
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ index f3f824d0ab1a2a72825c40b67192386479a0b34c..95ed6cb7b94797187d1011cab344e187
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 ad896c8a3060f5c8d85a8b5707317de646bf9cae..0df4672abb5e87587da8712b6febf6312e241cda 100644
|
index 1bbd8b475cdc57fb15ca05ffe122220a5539da10..7f39e36037d55278d15399196459e51b885c5d1e 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
|
||||||
@@ -2865,7 +2865,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -2838,7 +2838,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
// Spigot Start
|
// Spigot Start
|
||||||
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
||||||
// Paper start
|
// Paper start
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ index 6d7356cc07da58b1cef8d8963e790251d765de2c..601b9867d839f4928ba993ee8f00df9c
|
|||||||
|
|
||||||
public boolean fixVoidTrading = true;
|
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
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
index 0df4672abb5e87587da8712b6febf6312e241cda..1818c5ae88c331fb900470436f72049165c9e9f4 100644
|
index 7f39e36037d55278d15399196459e51b885c5d1e..66509fa23bfcde70abd3917eb774cf48d5d6da93 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
|
||||||
@@ -825,7 +825,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -798,7 +798,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
timings.doSounds.stopTiming(); // Spigot
|
timings.doSounds.stopTiming(); // Spigot
|
||||||
regionizedWorldData.setHandlingTick(false); // Folia - regionised ticking
|
regionizedWorldData.setHandlingTick(false); // Folia - regionised ticking
|
||||||
gameprofilerfiller.pop();
|
gameprofilerfiller.pop();
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ 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
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index 778de435ca3c13ccc2f2d86030e3529436a2d945..cac747a46cccf8b115917a72340e9b81e7a437c9 100644
|
index e1f50adfa216320bc53b460d11666064cb58c969..c934341c17caf4696065ac6c39bdfef570c62f13 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
|
||||||
@@ -216,8 +216,10 @@ public class KaiijuConfig {
|
@@ -211,8 +211,10 @@ public class KaiijuConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String serverModName = "Kaiiju";
|
public static String serverModName = "Kaiiju";
|
||||||
@@ -20,7 +20,7 @@ index 778de435ca3c13ccc2f2d86030e3529436a2d945..cac747a46cccf8b115917a72340e9b81
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index ee15661227754149164893d6acf678d13b2e1b27..0c50b516d0ff1c2812a877b57148f01861f8027f 100644
|
index 27b57db24587337ccdce29e492052ca419863323..fc6279a39fd5e1bd02b2d9e77f451cd9ba1baf78 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -566,6 +566,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -566,6 +566,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
|||||||
@@ -319,10 +319,10 @@ index 991e4c19763a34a6fead88363e007c2d11aad836..24a2d3f496727790f63cb66a2534d442
|
|||||||
dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands();
|
dev.kaiijumc.kaiiju.KaiijuConfig.registerCommands();
|
||||||
// Kaiiju end
|
// Kaiiju end
|
||||||
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 1818c5ae88c331fb900470436f72049165c9e9f4..7115a481bc8805333aa36af334132f98da9d8742 100644
|
index 245c3e63588379f51780963ba91bc6bf0a3feda6..761019f86983daaea4fface519e052f8fb6de1cd 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
|
||||||
@@ -849,6 +849,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -822,6 +822,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
} // Folia end - region threading
|
} // Folia end - region threading
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,21 +330,21 @@ index 1818c5ae88c331fb900470436f72049165c9e9f4..7115a481bc8805333aa36af334132f98
|
|||||||
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
|
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
|
||||||
timings.entityTick.startTiming(); // Spigot
|
timings.entityTick.startTiming(); // Spigot
|
||||||
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
|
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
|
||||||
@@ -871,6 +872,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -844,6 +845,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
entity.stopRiding();
|
entity.stopRiding();
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Kaiiju start
|
+ // Kaiiju start
|
||||||
+ if (kaiijuConfig.enableEntityThrottling) {
|
+ if (kaiijuConfig.enableEntityThrottling) {
|
||||||
+ dev.kaiijumc.kaiiju.KaiijuEntityThrottler.EntityThrottlerReturn throttle = regionizedWorldData.entityThrottler.tickLimiterShouldSkip(entity);
|
+ dev.kaiijumc.kaiiju.KaiijuEntityThrottler.EntityThrottlerReturn throttle = regionizedWorldData.entityThrottler.tickLimiterShouldSkip(entity);
|
||||||
+ if (throttle.remove && !entity.hasCustomName()) entity.remove(Entity.RemovalReason.DISCARDED);
|
+ if (throttle.remove) entity.remove(Entity.RemovalReason.DISCARDED);
|
||||||
+ if (throttle.skip) return;
|
+ if (throttle.skip) return;
|
||||||
+ }
|
+ }
|
||||||
+ // Kaiiju end
|
+ // Kaiiju end
|
||||||
gameprofilerfiller.push("tick");
|
gameprofilerfiller.push("tick");
|
||||||
this.guardEntityTick(this::tickNonPassenger, entity);
|
this.guardEntityTick(this::tickNonPassenger, entity);
|
||||||
gameprofilerfiller.pop();
|
gameprofilerfiller.pop();
|
||||||
@@ -878,6 +886,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -851,6 +859,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,15 +5,12 @@ 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
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index b971f35b69a930dddcf603207f524dc95e09f0fd..03895d35c02ff9422aaa0177eb0aa40e03fdc925 100644
|
index b971f35b69a930dddcf603207f524dc95e09f0fd..135573308662845ecc73fde1c620345e1f372538 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -4029,12 +4029,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -4031,10 +4031,15 @@ 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) -> {
|
(chunks) -> {
|
||||||
- ServerLevel.makeObsidianPlatform(destination, null, targetPos);
|
ServerLevel.makeObsidianPlatform(destination, null, targetPos);
|
||||||
+ //ServerLevel.makeObsidianPlatform(destination, null, targetPos); // Kaiiju - Vanilla end teleportation - moved down
|
|
||||||
|
|
||||||
+ // Kaiiju start - Vanilla end teleportation
|
+ // Kaiiju start - Vanilla end teleportation
|
||||||
+ Vec3 finalPos;
|
+ Vec3 finalPos;
|
||||||
@@ -28,23 +25,3 @@ index b971f35b69a930dddcf603207f524dc95e09f0fd..03895d35c02ff9422aaa0177eb0aa40e
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -4221,6 +4226,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(
|
|
||||||
@@ -4279,7 +4288,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
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ 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
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index cac747a46cccf8b115917a72340e9b81e7a437c9..a3c15f1009dad095b9411242e2d0347a6141984b 100644
|
index c934341c17caf4696065ac6c39bdfef570c62f13..f49510c999ce5241f26dc9ba90a6148bf31467c7 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
|
||||||
@@ -212,7 +212,10 @@ public class KaiijuConfig {
|
@@ -207,7 +207,10 @@ public class KaiijuConfig {
|
||||||
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
alternateKeepAlive = getBoolean("network.alternate-keepalive", alternateKeepAlive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ 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
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index a3c15f1009dad095b9411242e2d0347a6141984b..8c872b2ad341f0105275209201fda03706535161 100644
|
index f49510c999ce5241f26dc9ba90a6148bf31467c7..b23f2df433d7ebc871f4009081c28ed9054d91c7 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
|
||||||
@@ -213,9 +213,11 @@ public class KaiijuConfig {
|
@@ -208,9 +208,11 @@ public class KaiijuConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean disableVanishApi = false;
|
public static boolean disableVanishApi = false;
|
||||||
@@ -21,10 +21,10 @@ index a3c15f1009dad095b9411242e2d0347a6141984b..8c872b2ad341f0105275209201fda037
|
|||||||
|
|
||||||
public static String serverModName = "Kaiiju";
|
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
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
index c0ad878cd29e2f72b7899d9539031b15ccbf6193..53f5bf8e6660f25290d4e64aca9c2911921b9fed 100644
|
index 817f79bfca1aec161cb4635b9c7a8e21b14db7eb..bba90683202b47284208416a37724e9d54266ffa 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
@@ -2138,6 +2138,7 @@ public class ServerPlayer extends Player {
|
@@ -2081,6 +2081,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void awardStat(Stat<?> stat, int amount) {
|
public void awardStat(Stat<?> stat, int amount) {
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ index 9f0095f2196133a8bcffd5306aa9ac0b99b2f8d7..31d66bb2fcf4bb7262df2d8006e307fe
|
|||||||
|
|
||||||
public boolean fixVoidTrading = true;
|
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
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42597d0816 100644
|
index bba90683202b47284208416a37724e9d54266ffa..6bbbd7d4a409140df65f52f36e413c67ebac5561 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
@@ -792,7 +792,7 @@ public class ServerPlayer extends Player {
|
@@ -734,7 +734,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onInsideBlock(BlockState state) {
|
protected void onInsideBlock(BlockState state) {
|
||||||
@@ -36,7 +36,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -839,9 +839,9 @@ public class ServerPlayer extends Player {
|
@@ -781,9 +781,9 @@ public class ServerPlayer extends Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.trackStartFallingPosition();
|
this.trackStartFallingPosition();
|
||||||
@@ -916,7 +916,7 @@ public class ServerPlayer extends Player {
|
@@ -858,7 +858,7 @@ public class ServerPlayer extends Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.tickCount % 20 == 0) {
|
if (this.tickCount % 20 == 0) {
|
||||||
@@ -57,7 +57,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border
|
// CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border
|
||||||
@@ -945,7 +945,7 @@ public class ServerPlayer extends Player {
|
@@ -887,7 +887,7 @@ public class ServerPlayer extends Player {
|
||||||
@Override
|
@Override
|
||||||
public void resetFallDistance() {
|
public void resetFallDistance() {
|
||||||
if (this.getHealth() > 0.0F && this.startingToFallPosition != null) {
|
if (this.getHealth() > 0.0F && this.startingToFallPosition != null) {
|
||||||
@@ -66,7 +66,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.startingToFallPosition = null;
|
this.startingToFallPosition = null;
|
||||||
@@ -964,7 +964,7 @@ public class ServerPlayer extends Player {
|
@@ -906,7 +906,7 @@ public class ServerPlayer extends Player {
|
||||||
if (this.enteredLavaOnVehiclePosition == null) {
|
if (this.enteredLavaOnVehiclePosition == null) {
|
||||||
this.enteredLavaOnVehiclePosition = this.position();
|
this.enteredLavaOnVehiclePosition = this.position();
|
||||||
} else {
|
} else {
|
||||||
@@ -75,7 +75,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1168,7 +1168,7 @@ public class ServerPlayer extends Player {
|
@@ -1110,7 +1110,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
this.handleTeamKill(s, s1, ObjectiveCriteria.TEAM_KILL);
|
this.handleTeamKill(s, s1, ObjectiveCriteria.TEAM_KILL);
|
||||||
this.handleTeamKill(s1, s, ObjectiveCriteria.KILLED_BY_TEAM);
|
this.handleTeamKill(s1, s, ObjectiveCriteria.KILLED_BY_TEAM);
|
||||||
@@ -84,7 +84,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1286,7 +1286,7 @@ public class ServerPlayer extends Player {
|
@@ -1228,7 +1228,7 @@ public class ServerPlayer extends Player {
|
||||||
this.wonGame = false;
|
this.wonGame = false;
|
||||||
|
|
||||||
this.respawn((player) -> {
|
this.respawn((player) -> {
|
||||||
@@ -93,7 +93,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1787,14 +1787,14 @@ public class ServerPlayer extends Player {
|
@@ -1730,14 +1730,14 @@ public class ServerPlayer extends Player {
|
||||||
maindimensionkey1 = resourcekey1;
|
maindimensionkey1 = resourcekey1;
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
@@ -111,7 +111,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (maindimensionkey1 != Level.NETHER) { // CraftBukkit
|
if (maindimensionkey1 != Level.NETHER) { // CraftBukkit
|
||||||
@@ -1872,7 +1872,7 @@ public class ServerPlayer extends Player {
|
@@ -1815,7 +1815,7 @@ public class ServerPlayer extends Player {
|
||||||
{
|
{
|
||||||
Either<Player.BedSleepingProblem, Unit> either = super.startSleepInBed(blockposition, force).ifRight((unit) -> {
|
Either<Player.BedSleepingProblem, Unit> either = super.startSleepInBed(blockposition, force).ifRight((unit) -> {
|
||||||
this.awardStat(Stats.SLEEP_IN_BED);
|
this.awardStat(Stats.SLEEP_IN_BED);
|
||||||
@@ -120,7 +120,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!this.serverLevel().canSleepThroughNights()) {
|
if (!this.serverLevel().canSleepThroughNights()) {
|
||||||
@@ -2158,7 +2158,7 @@ public class ServerPlayer extends Player {
|
@@ -2101,7 +2101,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void triggerRecipeCrafted(Recipe<?> recipe, List<ItemStack> ingredients) {
|
public void triggerRecipeCrafted(Recipe<?> recipe, List<ItemStack> ingredients) {
|
||||||
@@ -129,7 +129,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2287,14 +2287,14 @@ public class ServerPlayer extends Player {
|
@@ -2230,14 +2230,14 @@ public class ServerPlayer extends Player {
|
||||||
this.levitationStartPos = this.position();
|
this.levitationStartPos = this.position();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2305,7 +2305,7 @@ public class ServerPlayer extends Player {
|
@@ -2248,7 +2248,7 @@ public class ServerPlayer extends Player {
|
||||||
this.levitationStartPos = null;
|
this.levitationStartPos = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2865,7 +2865,7 @@ public class ServerPlayer extends Player {
|
@@ -2808,7 +2808,7 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateUsingItem(ItemStack stack) {
|
protected void updateUsingItem(ItemStack stack) {
|
||||||
@@ -164,7 +164,7 @@ index 53f5bf8e6660f25290d4e64aca9c2911921b9fed..3c1871a879a14d38e56b0c31a73b2f42
|
|||||||
super.updateUsingItem(stack);
|
super.updateUsingItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2894,7 +2894,7 @@ public class ServerPlayer extends Player {
|
@@ -2837,7 +2837,7 @@ public class ServerPlayer extends Player {
|
||||||
Entity entity = item.getOwner();
|
Entity entity = item.getOwner();
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ 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
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index 8c872b2ad341f0105275209201fda03706535161..9b118a6e22264c88c0460016822b1920631fff85 100644
|
index b23f2df433d7ebc871f4009081c28ed9054d91c7..ec71f3f52cb8f7931aabd94619d2e7a24491d7ad 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
|
||||||
@@ -214,10 +214,12 @@ public class KaiijuConfig {
|
@@ -209,10 +209,12 @@ public class KaiijuConfig {
|
||||||
|
|
||||||
public static boolean disableVanishApi = false;
|
public static boolean disableVanishApi = false;
|
||||||
public static boolean disablePlayerStats = false;
|
public static boolean disablePlayerStats = false;
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ 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
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index 9b118a6e22264c88c0460016822b1920631fff85..95015955a8076bc903c012704b57b1b84286aaae 100644
|
index ec71f3f52cb8f7931aabd94619d2e7a24491d7ad..fa2a763e5784e7dae02c94a13751cbf746b6eee8 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
|
||||||
@@ -215,11 +215,13 @@ public class KaiijuConfig {
|
@@ -210,11 +210,13 @@ public class KaiijuConfig {
|
||||||
public static boolean disableVanishApi = false;
|
public static boolean disableVanishApi = false;
|
||||||
public static boolean disablePlayerStats = false;
|
public static boolean disablePlayerStats = false;
|
||||||
public static boolean disableArmSwingEvent = false;
|
public static boolean disableArmSwingEvent = false;
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ 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
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
||||||
index 95015955a8076bc903c012704b57b1b84286aaae..6df1720159383c2f536b40ded1092a437c1a20af 100644
|
index fa2a763e5784e7dae02c94a13751cbf746b6eee8..ebfa9e1dcca5ea8272e796f0409902d92b59ee76 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,10 +206,12 @@ public class KaiijuConfig {
|
@@ -201,10 +201,12 @@ public class KaiijuConfig {
|
||||||
|
|
||||||
public static boolean sendNullEntityPackets = true;
|
public static boolean sendNullEntityPackets = true;
|
||||||
public static boolean alternateKeepAlive = false;
|
public static boolean alternateKeepAlive = false;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Async path processing
|
|||||||
|
|
||||||
|
|
||||||
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 6df1720159383c2f536b40ded1092a437c1a20af..fc88b9f1e7e8f5858a91deeca2a5d51266a79a93 100644
|
index ebfa9e1dcca5ea8272e796f0409902d92b59ee76..6be4abdd16f2d57a80dbe175a91ff304fd17a7db 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
|
||||||
@@ -12,6 +12,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
@@ -12,6 +12,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@@ -16,13 +16,14 @@ index 6df1720159383c2f536b40ded1092a437c1a20af..fc88b9f1e7e8f5858a91deeca2a5d512
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@@ -218,12 +219,26 @@ public class KaiijuConfig {
|
@@ -213,12 +214,28 @@ public class KaiijuConfig {
|
||||||
public static boolean disablePlayerStats = false;
|
public static boolean disablePlayerStats = false;
|
||||||
public static boolean disableArmSwingEvent = false;
|
public static boolean disableArmSwingEvent = false;
|
||||||
public static boolean disableEnsureTickThreadChecks = false;
|
public static boolean disableEnsureTickThreadChecks = false;
|
||||||
+ public static boolean asyncPathProcessing = false;
|
+ public static boolean asyncPathProcessing = false;
|
||||||
+ public static int asyncPathProcessingMaxThreads = 0;
|
+ public static int asyncPathProcessingMaxThreads = 0;
|
||||||
+ public static int asyncPathProcessingKeepalive = 60;
|
+ public static int asyncPathProcessingKeepalive = 60;
|
||||||
|
+ public static int asyncPathProcessingQueueCapacity = 4096;
|
||||||
|
|
||||||
private static void optimizationSettings() {
|
private static void optimizationSettings() {
|
||||||
disableVanishApi = getBoolean("optimization.disable-vanish-api", disableVanishApi);
|
disableVanishApi = getBoolean("optimization.disable-vanish-api", disableVanishApi);
|
||||||
@@ -32,6 +33,7 @@ index 6df1720159383c2f536b40ded1092a437c1a20af..fc88b9f1e7e8f5858a91deeca2a5d512
|
|||||||
+ asyncPathProcessing = getBoolean("optimization.async-path-processing.enable", asyncPathProcessing);
|
+ asyncPathProcessing = getBoolean("optimization.async-path-processing.enable", asyncPathProcessing);
|
||||||
+ asyncPathProcessingMaxThreads = getInt("optimization.async-path-processing.max-threads", asyncPathProcessingMaxThreads);
|
+ asyncPathProcessingMaxThreads = getInt("optimization.async-path-processing.max-threads", asyncPathProcessingMaxThreads);
|
||||||
+ asyncPathProcessingKeepalive = getInt("optimization.async-path-processing.keepalive", asyncPathProcessingKeepalive);
|
+ asyncPathProcessingKeepalive = getInt("optimization.async-path-processing.keepalive", asyncPathProcessingKeepalive);
|
||||||
|
+ asyncPathProcessingQueueCapacity = getInt("optimization.async-path-processing.queue-capacity", asyncPathProcessingQueueCapacity);
|
||||||
+ if (asyncPathProcessingMaxThreads < 0)
|
+ if (asyncPathProcessingMaxThreads < 0)
|
||||||
+ asyncPathProcessingMaxThreads = Math.max(Runtime.getRuntime().availableProcessors() + asyncPathProcessingMaxThreads, 1);
|
+ asyncPathProcessingMaxThreads = Math.max(Runtime.getRuntime().availableProcessors() + asyncPathProcessingMaxThreads, 1);
|
||||||
+ else if (asyncPathProcessingMaxThreads == 0)
|
+ else if (asyncPathProcessingMaxThreads == 0)
|
||||||
@@ -338,7 +340,7 @@ index 0000000000000000000000000000000000000000..6b91852238f80d236fc44f766b115267
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java b/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java b/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..2a54fa6d733cb5d406fd218161448197515be7fb
|
index 0000000000000000000000000000000000000000..a6de8906d1629c60523c02681379ccdcaa22b588
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java
|
||||||
@@ -0,0 +1,53 @@
|
@@ -0,0 +1,53 @@
|
||||||
@@ -346,7 +348,6 @@ index 0000000000000000000000000000000000000000..2a54fa6d733cb5d406fd218161448197
|
|||||||
+
|
+
|
||||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
+
|
+
|
||||||
+import dev.kaiijumc.kaiiju.KaiijuConfig;
|
|
||||||
+import net.minecraft.world.level.pathfinder.Path;
|
+import net.minecraft.world.level.pathfinder.Path;
|
||||||
+import net.minecraft.world.entity.Entity;
|
+import net.minecraft.world.entity.Entity;
|
||||||
+
|
+
|
||||||
@@ -363,13 +364,14 @@ index 0000000000000000000000000000000000000000..2a54fa6d733cb5d406fd218161448197
|
|||||||
+
|
+
|
||||||
+ private static final Executor pathProcessingExecutor = new ThreadPoolExecutor(
|
+ private static final Executor pathProcessingExecutor = new ThreadPoolExecutor(
|
||||||
+ 1,
|
+ 1,
|
||||||
+ KaiijuConfig.asyncPathProcessingMaxThreads,
|
+ dev.kaiijumc.kaiiju.KaiijuConfig.asyncPathProcessingMaxThreads,
|
||||||
+ KaiijuConfig.asyncPathProcessingKeepalive, TimeUnit.SECONDS,
|
+ dev.kaiijumc.kaiiju.KaiijuConfig.asyncPathProcessingKeepalive,
|
||||||
+ new LinkedBlockingQueue<>(),
|
+ TimeUnit.SECONDS,
|
||||||
+ new ThreadFactoryBuilder()
|
+ new ArrayBlockingQueue<>(dev.kaiijumc.kaiiju.KaiijuConfig.asyncPathProcessingQueueCapacity),
|
||||||
+ .setNameFormat("petal-path-processor-%d")
|
+ new ThreadFactoryBuilder()
|
||||||
+ .setPriority(Thread.NORM_PRIORITY - 2)
|
+ .setNameFormat("petal-path-processor-%d")
|
||||||
+ .build()
|
+ .setPriority(Thread.NORM_PRIORITY - 2)
|
||||||
|
+ .build()
|
||||||
+ );
|
+ );
|
||||||
+
|
+
|
||||||
+ protected static CompletableFuture<Void> queue(@NotNull AsyncPath path) {
|
+ protected static CompletableFuture<Void> queue(@NotNull AsyncPath path) {
|
||||||
@@ -397,10 +399,10 @@ index 0000000000000000000000000000000000000000..2a54fa6d733cb5d406fd218161448197
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorCache.java b/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorCache.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorCache.java b/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorCache.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..3213fed7cea3ebfc364f4d6603b95f4263222c76
|
index 0000000000000000000000000000000000000000..121eda164714650f76bb6c8495ef375d8a00d812
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorCache.java
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorCache.java
|
||||||
@@ -0,0 +1,45 @@
|
@@ -0,0 +1,42 @@
|
||||||
+package dev.kaiijumc.kaiiju.path;
|
+package dev.kaiijumc.kaiiju.path;
|
||||||
+
|
+
|
||||||
+import net.minecraft.world.level.pathfinder.NodeEvaluator;
|
+import net.minecraft.world.level.pathfinder.NodeEvaluator;
|
||||||
@@ -417,13 +419,13 @@ index 0000000000000000000000000000000000000000..3213fed7cea3ebfc364f4d6603b95f42
|
|||||||
+ private static final Map<NodeEvaluatorFeatures, ConcurrentLinkedQueue<NodeEvaluator>> threadLocalNodeEvaluators = new ConcurrentHashMap<>();
|
+ private static final Map<NodeEvaluatorFeatures, ConcurrentLinkedQueue<NodeEvaluator>> threadLocalNodeEvaluators = new ConcurrentHashMap<>();
|
||||||
+ private static final Map<NodeEvaluator, NodeEvaluatorGenerator> nodeEvaluatorToGenerator = new ConcurrentHashMap<>();
|
+ private static final Map<NodeEvaluator, NodeEvaluatorGenerator> nodeEvaluatorToGenerator = new ConcurrentHashMap<>();
|
||||||
+
|
+
|
||||||
+ private static @NotNull Queue<NodeEvaluator> getQueueForFeatures(@NotNull NodeEvaluatorFeatures nodeEvaluatorFeatures) {
|
+ private static @NotNull Queue<NodeEvaluator> getDequeForGenerator(@NotNull NodeEvaluatorFeatures nodeEvaluatorFeatures) {
|
||||||
+ return threadLocalNodeEvaluators.computeIfAbsent(nodeEvaluatorFeatures, (key) -> new ConcurrentLinkedQueue<>());
|
+ return threadLocalNodeEvaluators.computeIfAbsent(nodeEvaluatorFeatures, (key) -> new ConcurrentLinkedQueue<>());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static @NotNull NodeEvaluator takeNodeEvaluator(@NotNull NodeEvaluatorGenerator generator, @NotNull NodeEvaluator localNodeEvaluator) {
|
+ public static @NotNull NodeEvaluator takeNodeEvaluator(@NotNull NodeEvaluatorGenerator generator, @NotNull NodeEvaluator localNodeEvaluator) {
|
||||||
+ final NodeEvaluatorFeatures nodeEvaluatorFeatures = NodeEvaluatorFeatures.fromNodeEvaluator(localNodeEvaluator);
|
+ final NodeEvaluatorFeatures nodeEvaluatorFeatures = NodeEvaluatorFeatures.fromNodeEvaluator(localNodeEvaluator);
|
||||||
+ NodeEvaluator nodeEvaluator = getQueueForFeatures(nodeEvaluatorFeatures).poll();
|
+ NodeEvaluator nodeEvaluator = getDequeForGenerator(nodeEvaluatorFeatures).poll();
|
||||||
+
|
+
|
||||||
+ if (nodeEvaluator == null) {
|
+ if (nodeEvaluator == null) {
|
||||||
+ nodeEvaluator = generator.generate(nodeEvaluatorFeatures);
|
+ nodeEvaluator = generator.generate(nodeEvaluatorFeatures);
|
||||||
@@ -435,16 +437,13 @@ index 0000000000000000000000000000000000000000..3213fed7cea3ebfc364f4d6603b95f42
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static void returnNodeEvaluator(@NotNull NodeEvaluator nodeEvaluator) {
|
+ public static void returnNodeEvaluator(@NotNull NodeEvaluator nodeEvaluator) {
|
||||||
+ final NodeEvaluatorGenerator generator = nodeEvaluatorToGenerator.remove(nodeEvaluator);
|
+ final NodeEvaluatorFeatures nodeEvaluatorFeatures = NodeEvaluatorFeatures.fromNodeEvaluator(nodeEvaluator);
|
||||||
|
+ final var generator = nodeEvaluatorToGenerator.remove(nodeEvaluator);
|
||||||
+ Validate.notNull(generator, "NodeEvaluator already returned");
|
+ Validate.notNull(generator, "NodeEvaluator already returned");
|
||||||
+
|
+
|
||||||
+ final NodeEvaluatorFeatures nodeEvaluatorFeatures = NodeEvaluatorFeatures.fromNodeEvaluator(nodeEvaluator);
|
+ getDequeForGenerator(nodeEvaluatorFeatures).offer(nodeEvaluator);
|
||||||
+ getQueueForFeatures(nodeEvaluatorFeatures).offer(nodeEvaluator);
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static void removeNodeEvaluator(@NotNull NodeEvaluator nodeEvaluator) {
|
|
||||||
+ nodeEvaluatorToGenerator.remove(nodeEvaluator);
|
|
||||||
+ }
|
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorFeatures.java b/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorFeatures.java
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorFeatures.java b/src/main/java/dev/kaiijumc/kaiiju/path/NodeEvaluatorFeatures.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
@@ -514,14 +513,14 @@ index 0000000000000000000000000000000000000000..130d61324679c8600faa52255f3ad99f
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
index a8b23b1594d2b39568c68c93a8a1b936457672bc..af4305813abdb5db5e35ba4466e3e0b717e78cda 100644
|
index a8b23b1594d2b39568c68c93a8a1b936457672bc..8bd27e1a60c1a92350f4954764ea17914959e6dc 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
@@ -294,6 +294,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
@@ -294,6 +294,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public LivingEntity getTarget() {
|
public LivingEntity getTarget() {
|
||||||
+ if (Thread.currentThread().getName().contains("petal-path-processor")) return this.target; // Kaiiju - Don't reset target when async pathfinding!
|
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(this)) return this.target; // Kaiiju - for the async path processor
|
||||||
// Folia start - region threading
|
// Folia start - region threading
|
||||||
if (!io.papermc.paper.util.TickThread.isTickThreadFor(this.target)) {
|
if (!io.papermc.paper.util.TickThread.isTickThreadFor(this.target)) {
|
||||||
this.target = null;
|
this.target = null;
|
||||||
@@ -579,7 +578,7 @@ index d4c91e0a0c64fcb7f1145de3f30134cb1f1f8ee6..ef5ec638bcd88df6eb93746868e863db
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
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
|
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 98bf17441da3169d49de55fe89d79ebe250a2b7e..5f3b38830c786deed161bdd2efd2d3c4071d34ec 100644
|
index 98bf17441da3169d49de55fe89d79ebe250a2b7e..df85430912bb00cef1994ded357ca93680f0650d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||||
@@ -21,6 +21,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
@@ -21,6 +21,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||||
@@ -590,19 +589,19 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..5f3b38830c786deed161bdd2efd2d3c4
|
|||||||
@Nullable
|
@Nullable
|
||||||
private BlockPos lastTargetPos;
|
private BlockPos lastTargetPos;
|
||||||
private float speedModifier;
|
private float speedModifier;
|
||||||
@@ -42,9 +43,10 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
@@ -42,7 +43,10 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||||
Brain<?> brain = entity.getBrain();
|
Brain<?> brain = entity.getBrain();
|
||||||
WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
||||||
boolean bl = this.reachedTarget(entity, walkTarget);
|
boolean bl = this.reachedTarget(entity, walkTarget);
|
||||||
- if (!bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) {
|
- if (!bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) {
|
||||||
+ if (!dev.kaiijumc.kaiiju.KaiijuConfig.asyncPathProcessing && !bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { // Kaiiju - petal - async path processing means we can't know if the path is reachable here
|
+ // Kaiiju start - petal - async path processing means we can't know if the path is reachable here
|
||||||
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.asyncPathProcessing && !bl) return true;
|
||||||
|
+ else if (!dev.kaiijumc.kaiiju.KaiijuConfig.asyncPathProcessing && !bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) {
|
||||||
|
+ // Kaiiju end
|
||||||
this.lastTargetPos = walkTarget.getTarget().currentBlockPosition();
|
this.lastTargetPos = walkTarget.getTarget().currentBlockPosition();
|
||||||
return true;
|
return true;
|
||||||
+ } else if (dev.kaiijumc.kaiiju.KaiijuConfig.asyncPathProcessing && !bl) { return true; // Kaiiju - async pathfinding
|
|
||||||
} else {
|
} else {
|
||||||
brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
@@ -58,6 +62,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||||
if (bl) {
|
|
||||||
@@ -58,6 +60,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canStillUse(ServerLevel world, Mob entity, long time) {
|
protected boolean canStillUse(ServerLevel world, Mob entity, long time) {
|
||||||
@@ -610,7 +609,7 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..5f3b38830c786deed161bdd2efd2d3c4
|
|||||||
if (this.path != null && this.lastTargetPos != null) {
|
if (this.path != null && this.lastTargetPos != null) {
|
||||||
Optional<WalkTarget> optional = entity.getBrain().getMemory(MemoryModuleType.WALK_TARGET);
|
Optional<WalkTarget> optional = entity.getBrain().getMemory(MemoryModuleType.WALK_TARGET);
|
||||||
boolean bl = optional.map(MoveToTargetSink::isWalkTargetSpectator).orElse(false);
|
boolean bl = optional.map(MoveToTargetSink::isWalkTargetSpectator).orElse(false);
|
||||||
@@ -82,12 +85,68 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
@@ -82,12 +87,74 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void start(ServerLevel serverLevel, Mob mob, long l) {
|
protected void start(ServerLevel serverLevel, Mob mob, long l) {
|
||||||
@@ -649,16 +648,22 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..5f3b38830c786deed161bdd2efd2d3c4
|
|||||||
+ if (!canReach) {
|
+ if (!canReach) {
|
||||||
+ Optional<WalkTarget> walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET);
|
+ Optional<WalkTarget> walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET);
|
||||||
+
|
+
|
||||||
+ if (!walkTarget.isPresent()) return;
|
+ if (walkTarget.isPresent()) {
|
||||||
+
|
+ BlockPos blockPos = walkTarget.get().getTarget().currentBlockPosition();
|
||||||
+ BlockPos blockPos = walkTarget.get().getTarget().currentBlockPosition();
|
+ Vec3 vec3 = DefaultRandomPos.getPosTowards((PathfinderMob)mob, 10, 7, Vec3.atBottomCenterOf(blockPos), (float)Math.PI / 2F);
|
||||||
+ Vec3 vec3 = DefaultRandomPos.getPosTowards((PathfinderMob)mob, 10, 7, Vec3.atBottomCenterOf(blockPos), (float)Math.PI / 2F);
|
+ if (vec3 != null) {
|
||||||
+ if (vec3 != null) {
|
+ // try recalculating the path using a random position
|
||||||
+ // try recalculating the path using a random position
|
+ this.path = mob.getNavigation().createPath(vec3.x, vec3.y, vec3.z, 0);
|
||||||
+ this.path = mob.getNavigation().createPath(vec3.x, vec3.y, vec3.z, 0);
|
+ this.finishedProcessing = false;
|
||||||
+ this.finishedProcessing = false;
|
+ return;
|
||||||
+ return;
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ // we failed, erase and move on
|
||||||
|
+ brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
||||||
|
+ this.path = null;
|
||||||
|
+
|
||||||
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ mob.getBrain().setMemory(MemoryModuleType.PATH, this.path);
|
+ mob.getBrain().setMemory(MemoryModuleType.PATH, this.path);
|
||||||
@@ -669,7 +674,7 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..5f3b38830c786deed161bdd2efd2d3c4
|
|||||||
+ Brain<?> brain = mob.getBrain();
|
+ Brain<?> brain = mob.getBrain();
|
||||||
+
|
+
|
||||||
+ if (path != null && this.lastTargetPos != null && brain.hasMemoryValue(MemoryModuleType.WALK_TARGET)) {
|
+ if (path != null && this.lastTargetPos != null && brain.hasMemoryValue(MemoryModuleType.WALK_TARGET)) {
|
||||||
+ WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get(); // we know isPresent = true
|
+ WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
||||||
+ if (walkTarget.getTarget().currentBlockPosition().distSqr(this.lastTargetPos) > 4.0D) {
|
+ if (walkTarget.getTarget().currentBlockPosition().distSqr(this.lastTargetPos) > 4.0D) {
|
||||||
+ this.start(serverLevel, mob, l);
|
+ this.start(serverLevel, mob, l);
|
||||||
+ }
|
+ }
|
||||||
@@ -679,7 +684,7 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..5f3b38830c786deed161bdd2efd2d3c4
|
|||||||
Path path = mob.getNavigation().getPath();
|
Path path = mob.getNavigation().getPath();
|
||||||
Brain<?> brain = mob.getBrain();
|
Brain<?> brain = mob.getBrain();
|
||||||
if (this.path != path) {
|
if (this.path != path) {
|
||||||
@@ -103,7 +162,23 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
@@ -103,7 +170,23 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1135,30 +1140,6 @@ index 97b763431bc5015448ee7a26a340635a932c950b..48109aebe34cbdfac3eceffb1c20aa84
|
|||||||
return new PathFinder(this.nodeEvaluator, range) {
|
return new PathFinder(this.nodeEvaluator, range) {
|
||||||
@Override
|
@Override
|
||||||
protected float distance(Node a, Node b) {
|
protected float distance(Node a, Node b) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
||||||
index b51155ad12515b2d0dd0f202580b9f455c114d9a..fd336bc5a209caf6fd7f85f781b2b0a303dbd5ec 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
||||||
@@ -242,6 +242,7 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
|
||||||
+ if (Thread.currentThread().getName().contains("petal-path-processor")) return Shapes.block(); // Kaiiju - async pathfinding - we cannot get block entities
|
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
|
||||||
return blockEntity instanceof ShulkerBoxBlockEntity ? Shapes.create(((ShulkerBoxBlockEntity)blockEntity).getBoundingBox(state)) : Shapes.block();
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
|
|
||||||
index e941a4ce35c1bcc84836d04fb97cb1e7f292ae42..26f3c25f2dfda5f7c6213746efa8b883b655d2e1 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
|
|
||||||
@@ -102,6 +102,7 @@ public class MovingPistonBlock extends BaseEntityBlock {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
|
||||||
+ if (Thread.currentThread().getName().contains("petal-path-processor")) return Shapes.empty(); // Kaiiju - async pathfinding - we cannot get block entities
|
|
||||||
PistonMovingBlockEntity pistonMovingBlockEntity = this.getBlockEntity(world, pos);
|
|
||||||
return pistonMovingBlockEntity != null ? pistonMovingBlockEntity.getCollisionShape(world, pos) : Shapes.empty();
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/Path.java b/src/main/java/net/minecraft/world/level/pathfinder/Path.java
|
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/Path.java b/src/main/java/net/minecraft/world/level/pathfinder/Path.java
|
||||||
index 2a335f277bd0e4b8ad0f60d8226eb8aaa80a871f..b2c3c459fae7d0cb5ef0fcbc2ff0e61c7b952087 100644
|
index 2a335f277bd0e4b8ad0f60d8226eb8aaa80a871f..b2c3c459fae7d0cb5ef0fcbc2ff0e61c7b952087 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/Path.java
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/Path.java
|
||||||
@@ -1190,10 +1171,10 @@ index 2a335f277bd0e4b8ad0f60d8226eb8aaa80a871f..b2c3c459fae7d0cb5ef0fcbc2ff0e61c
|
|||||||
return false;
|
return false;
|
||||||
} else if (o.nodes.size() != this.nodes.size()) {
|
} else if (o.nodes.size() != this.nodes.size()) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
index d23481453717f715124156b5d83f6448f720d049..7be397d884ec091e0f51ae48ee2c83b6f0e486ea 100644
|
index d23481453717f715124156b5d83f6448f720d049..d4cc2a5f99f8445be9a63c279e28032f11a91304 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||||
@@ -24,37 +24,80 @@ public class PathFinder {
|
@@ -24,37 +24,77 @@ public class PathFinder {
|
||||||
public final NodeEvaluator nodeEvaluator;
|
public final NodeEvaluator nodeEvaluator;
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private final BinaryHeap openSet = new BinaryHeap();
|
private final BinaryHeap openSet = new BinaryHeap();
|
||||||
@@ -1226,7 +1207,11 @@ index d23481453717f715124156b5d83f6448f720d049..7be397d884ec091e0f51ae48ee2c83b6
|
|||||||
+ Node node = nodeEvaluator.getStart();
|
+ Node node = nodeEvaluator.getStart();
|
||||||
+ // Kaiiju end
|
+ // Kaiiju end
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
+ dev.kaiijumc.kaiiju.path.NodeEvaluatorCache.removeNodeEvaluator(nodeEvaluator); // Kaiiju - petal - handle nodeEvaluatorGenerator
|
+ // Kaiiju start - petal - handle nodeEvaluatorGenerator
|
||||||
|
+ if (this.nodeEvaluatorGenerator != null) {
|
||||||
|
+ dev.kaiijumc.kaiiju.path.NodeEvaluatorCache.returnNodeEvaluator(nodeEvaluator);
|
||||||
|
+ }
|
||||||
|
+ // Kaiiju end
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
// Paper start - remove streams - and optimize collection
|
// Paper start - remove streams - and optimize collection
|
||||||
@@ -1242,16 +1227,12 @@ index d23481453717f715124156b5d83f6448f720d049..7be397d884ec091e0f51ae48ee2c83b6
|
|||||||
+ // Kaiiju start - petal - async path processing
|
+ // Kaiiju start - petal - async path processing
|
||||||
+ if (this.nodeEvaluatorGenerator == null) {
|
+ if (this.nodeEvaluatorGenerator == null) {
|
||||||
+ // run sync :(
|
+ // run sync :(
|
||||||
+ dev.kaiijumc.kaiiju.path.NodeEvaluatorCache.removeNodeEvaluator(nodeEvaluator);
|
+ return this.findPath(nodeEvaluator, world.getProfiler(), node, map, followRange, distance, rangeMultiplier);
|
||||||
+ return this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier);
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return new dev.kaiijumc.kaiiju.path.AsyncPath(Lists.newArrayList(), positions, () -> {
|
+ return new dev.kaiijumc.kaiiju.path.AsyncPath(Lists.newArrayList(), positions, () -> {
|
||||||
+ try {
|
+ try {
|
||||||
+ return this.processPath(nodeEvaluator, node, map, followRange, distance, rangeMultiplier);
|
+ return this.processPath(nodeEvaluator, node, map, followRange, distance, rangeMultiplier);
|
||||||
+ } catch (Exception e) {
|
|
||||||
+ e.printStackTrace();
|
|
||||||
+ return null;
|
|
||||||
+ } finally {
|
+ } finally {
|
||||||
+ nodeEvaluator.done();
|
+ nodeEvaluator.done();
|
||||||
+ dev.kaiijumc.kaiiju.path.NodeEvaluatorCache.returnNodeEvaluator(nodeEvaluator);
|
+ dev.kaiijumc.kaiiju.path.NodeEvaluatorCache.returnNodeEvaluator(nodeEvaluator);
|
||||||
@@ -1264,26 +1245,24 @@ index d23481453717f715124156b5d83f6448f720d049..7be397d884ec091e0f51ae48ee2c83b6
|
|||||||
- @Nullable
|
- @Nullable
|
||||||
+ //@Nullable // Kaiiju - Always not null
|
+ //@Nullable // Kaiiju - Always not null
|
||||||
// Paper start - optimize collection
|
// Paper start - optimize collection
|
||||||
private Path findPath(ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
- private Path findPath(ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||||
|
+ private Path findPath(NodeEvaluator nodeEvaluator, ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||||
profiler.push("find_path");
|
profiler.push("find_path");
|
||||||
profiler.markForCharting(MetricCategory.PATH_FINDING);
|
profiler.markForCharting(MetricCategory.PATH_FINDING);
|
||||||
+ // Kaiiju start - petal - split pathfinding into the original sync method for compat and processing for delaying
|
+ // Kaiiju start - petal - split pathfinding into the original sync method for compat and processing for delaying
|
||||||
+ try {
|
+ try {
|
||||||
+ return this.processPath(this.nodeEvaluator, startNode, positions, followRange, distance, rangeMultiplier);
|
+ return this.processPath(this.nodeEvaluator, startNode, positions, followRange, distance, rangeMultiplier);
|
||||||
+ } catch (Exception e) {
|
|
||||||
+ e.printStackTrace();
|
|
||||||
+ return null;
|
|
||||||
+ } finally {
|
+ } finally {
|
||||||
+ this.nodeEvaluator.done();
|
+ nodeEvaluator.done();
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ private synchronized @org.jetbrains.annotations.NotNull Path processPath(NodeEvaluator nodeEvaluator, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) { // sync to only use the caching functions in this class on a single thread
|
+ private synchronized Path processPath(NodeEvaluator nodeEvaluator, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) { // sync to only use the caching functions in this class on a single thread
|
||||||
+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty()); // ensure that we have at least one position, which means we'll always return a path
|
+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty()); // ensure that we have at least one position, which means we'll always return a path
|
||||||
+ // Kaiiju end
|
+ // Kaiiju end
|
||||||
// Set<Target> set = positions.keySet();
|
// Set<Target> set = positions.keySet();
|
||||||
startNode.g = 0.0F;
|
startNode.g = 0.0F;
|
||||||
startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection
|
startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection
|
||||||
@@ -91,7 +134,7 @@ public class PathFinder {
|
@@ -91,7 +131,7 @@ public class PathFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(node.distanceTo(startNode) >= followRange)) {
|
if (!(node.distanceTo(startNode) >= followRange)) {
|
||||||
@@ -1292,14 +1271,6 @@ index d23481453717f715124156b5d83f6448f720d049..7be397d884ec091e0f51ae48ee2c83b6
|
|||||||
|
|
||||||
for(int l = 0; l < k; ++l) {
|
for(int l = 0; l < k; ++l) {
|
||||||
Node node2 = this.neighbors[l];
|
Node node2 = this.neighbors[l];
|
||||||
@@ -123,6 +166,7 @@ public class PathFinder {
|
|
||||||
if (best == null || comparator.compare(path, best) < 0)
|
|
||||||
best = path;
|
|
||||||
}
|
|
||||||
+ //noinspection ConstantConditions // Kaiiju - petal - ignore this warning, we know that the above loop always runs at least once since positions is not empty
|
|
||||||
return best;
|
|
||||||
// Paper end
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||||
index 0e2b14e7dfedf209d63279c81723fd7955122d78..079b278e2e262af433bb5bd0c12b3d8db4fa12fc 100644
|
index 0e2b14e7dfedf209d63279c81723fd7955122d78..079b278e2e262af433bb5bd0c12b3d8db4fa12fc 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||||
|
|||||||
@@ -1,458 +0,0 @@
|
|||||||
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 762b763f271c3208b4f8a7e346897207ec5beb6c..a212a62bc2b43b55e9040e2de8360d6e55a7dd86 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -455,11 +479,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) {
|
|
||||||
@@ -649,7 +673,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
|
|
||||||
@@ -844,7 +868,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
|
|
||||||
Reference in New Issue
Block a user