Begin remigrate to Shiroha

uhm
This commit is contained in:
2026-07-14 11:32:51 +08:00
parent 5661499e95
commit 576a9a44c8
60 changed files with 379 additions and 379 deletions
@@ -12,7 +12,7 @@ index a4d608d64b7d3477c9144d93547fd3b4f39a1b02..8cb1cfefa0deb78c1773ba9913138f31
JvmProfiler.INSTANCE.start(Environment.SERVER);
}
+ moe.monnairealms.camellia.config.ConfigManager.initConfigs(); // Camellia - Config system framework - pre load config file
+ moe.monnairealms.camellia.config.ConfigManager.initConfigs(); // Shiroha - Config system framework - pre load config file
io.papermc.paper.plugin.PluginInitializerManager.load(options); // Paper
Bootstrap.bootStrap();
Bootstrap.validate();
@@ -24,7 +24,7 @@ index c6a4d52f76e10fcc57b2c49b07fbc2ef9bb90822..e305fd5850d333eb1a30572076b6475e
ca.spottedleaf.moonrise.common.util.MoonriseCommon.haltExecutors();
}
// Paper end - rewrite chunk system
+ moe.monnairealms.camellia.config.ConfigManager.saveConfigs(false); // Camellia - Config system framework - save config file
+ moe.monnairealms.camellia.config.ConfigManager.saveConfigs(false); // Shiroha - Config system framework - save config file
// Paper start - Improved watchdog support - move final shutdown items here
Util.shutdownExecutors();
this.onServerExit();
@@ -36,7 +36,7 @@ index cd5551c0221ad2a7b5c7d452d8d91ffc9711c3ee..17244a82d7591004a43c013748f3db05
this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
// Paper end - initialize global and world-defaults configuration
+ moe.monnairealms.camellia.config.ConfigManager.loadConfigFiles(); // Camellia - Config system framework - load config file
+ moe.monnairealms.camellia.config.ConfigManager.loadConfigFiles(); // Shiroha - Config system framework - load config file
this.server.spark.enableEarlyIfRequested(); // Paper - spark
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
if (this.convertOldUsers()) {
@@ -13,10 +13,10 @@ index a814512fcfb85312474ae2c2c21443843bf57831..5734af81b1f88fde952f498059c79116
public boolean moonrise$doesRegionFileNotExistNoIO(final int chunkX, final int chunkZ);
- public RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ);
+ public moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ); // Camellia - Configurable region file format
+ public moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ); // Shiroha - Configurable region file format
- public RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException;
+ public moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException; // Camellia - Configurable region file format
+ public moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException; // Shiroha - Configurable region file format
public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(
final int chunkX, final int chunkZ, final CompoundTag compound
@@ -29,7 +29,7 @@ index 3bb9b58ee97464687e348e23b99159226415c267..b6d4d9fac961aa4672ef2f4a19e2ae18
// Paper start - flush regionfiles on save
if (this.world.paperConfig().chunks.flushRegionsOnSave) {
- final RegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ); // Camellia - Configurable region file format
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ); // Shiroha - Configurable region file format
if (regionFile != null) {
regionFile.flush();
} // else: evicted from cache, which should have called flush
@@ -38,7 +38,7 @@ index 3bb9b58ee97464687e348e23b99159226415c267..b6d4d9fac961aa4672ef2f4a19e2ae18
public static interface IORunnable {
- public void run(final RegionFile regionFile) throws IOException;
+ public void run(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException; // Camellia - Configurable region file format
+ public void run(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException; // Shiroha - Configurable region file format
}
}
@@ -51,7 +51,7 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..084b64dbaa2807fa29e4ae787144fce2
public void moonrise$setWriteOnClose(final boolean value);
- public void moonrise$write(final RegionFile regionFile) throws IOException;
+ public void moonrise$write(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException; // Camellia - Configurable region file format
+ public void moonrise$write(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException; // Shiroha - Configurable region file format
}
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index e305fd5850d333eb1a30572076b6475e4428f7a7..78e9cf21fb5487e5eeec04e589c2a84c1e6b06af 100644
@@ -62,11 +62,11 @@ index e305fd5850d333eb1a30572076b6475e4428f7a7..78e9cf21fb5487e5eeec04e589c2a84c
for (ServerLevel level : this.getAllLevels()) {
String storageName = level.getChunkSource().chunkMap.getStorageName();
- LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", LEGACY_WORLD_NAMES_FOR_REALMS_LOG.getOrDefault(storageName, storageName));
+ LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", LEGACY_WORLD_NAMES_FOR_REALMS_LOG.getOrDefault(storageName, storageName)); // Camellia - Configurable region format
+ LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", LEGACY_WORLD_NAMES_FOR_REALMS_LOG.getOrDefault(storageName, storageName)); // Shiroha - Configurable region format
}
- LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved");
+ LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // Camellia - configurable region format
+ LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // Shiroha - configurable region format
}
return result;
@@ -79,7 +79,7 @@ index a7f2cfa9277c898038f6b9e0a3401db51012b64c..d6151f308e2e5864b6525409761aa6d9
import net.minecraft.world.level.chunk.storage.RegionFile;
-public record FileToUpgrade(RegionFile file, List<ChunkPos> chunksToUpgrade) {
+public record FileToUpgrade(moe.monnairealms.camellia.data.RegionFile file, List<ChunkPos> chunksToUpgrade) { // Camellia - Configurable region file format
+public record FileToUpgrade(moe.monnairealms.camellia.data.RegionFile file, List<ChunkPos> chunksToUpgrade) { // Shiroha - Configurable region file format
}
diff --git a/net/minecraft/util/worldupdate/RegionStorageUpgrader.java b/net/minecraft/util/worldupdate/RegionStorageUpgrader.java
index b228cd6c54e8c8998923ab332882d99092769c67..13ec3d38ffb6e0e87db621c9607c9dc3c6a7b31b 100644
@@ -90,7 +90,7 @@ index b228cd6c54e8c8998923ab332882d99092769c67..13ec3d38ffb6e0e87db621c9607c9dc3
private static final Logger LOGGER = LogUtils.getLogger();
private static final String NEW_DIRECTORY_PREFIX = "new_";
- private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
+ private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\." + moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat.getArgument() + "$"); // Camellia - Configurable region file format
+ private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\." + moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat.getArgument() + "$"); // Shiroha - Configurable region file format
private final DataFixer dataFixer;
private final UpgradeProgress upgradeProgress;
private final String type;
@@ -99,8 +99,8 @@ index b228cd6c54e8c8998923ab332882d99092769c67..13ec3d38ffb6e0e87db621c9607c9dc3
List<ChunkPos> chunkPositions = Lists.newArrayList();
- try (RegionFile regionSource = new RegionFile(info, regionFile.toPath(), regionFolder, true)) {
+ var regionFileInfo = new moe.monnairealms.camellia.utils.RegionCreatorInfo(info, regionFile.toPath(), regionFolder, true); // Camellia - Configurable region file format
+ try (moe.monnairealms.camellia.data.RegionFile regionSource = moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat.getCreator().newFile(regionFileInfo)) { // Camellia - Configurable region file format
+ var regionFileInfo = new moe.monnairealms.camellia.utils.RegionCreatorInfo(info, regionFile.toPath(), regionFolder, true); // Shiroha - Configurable region file format
+ try (moe.monnairealms.camellia.data.RegionFile regionSource = moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat.getCreator().newFile(regionFileInfo)) { // Shiroha - Configurable region file format
for (int x = 0; x < 32; x++) {
for (int z = 0; z < 32; z++) {
ChunkPos pos = new ChunkPos(x + xOffset, z + zOffset);
@@ -109,7 +109,7 @@ index b228cd6c54e8c8998923ab332882d99092769c67..13ec3d38ffb6e0e87db621c9607c9dc3
}
- private void onFileFinished(final RegionFile regionFile) {
+ private void onFileFinished(final moe.monnairealms.camellia.data.RegionFile regionFile) { // Camellia - Configurable region file format
+ private void onFileFinished(final moe.monnairealms.camellia.data.RegionFile regionFile) { // Shiroha - Configurable region file format
if (this.recreateRegionFiles) {
if (this.previousWriteFuture != null) {
this.previousWriteFuture.join();
@@ -122,7 +122,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..476aa2af20caeb8da293bd9e6c7467e3
import org.slf4j.Logger;
-public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile { // Paper - rewrite chunk system
+public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile , moe.monnairealms.camellia.data.RegionFile{ // Paper - rewrite chunk system // Camellia - Configurable region file format
+public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile , moe.monnairealms.camellia.data.RegionFile{ // Paper - rewrite chunk system // Shiroha - Configurable region file format
private static final Logger LOGGER = LogUtils.getLogger();
public static final int MAX_CHUNK_SIZE = 500 * 1024 * 1024; // Paper - don't write garbage data to disk if writing serialization fails
private static final int SECTOR_BYTES = 4096;
@@ -131,7 +131,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..476aa2af20caeb8da293bd9e6c7467e3
}
- boolean recalculateHeader() throws IOException {
+ public boolean recalculateHeader() throws IOException { // Camellia - Configurable region file format
+ public boolean recalculateHeader() throws IOException { // Shiroha - Configurable region file format
if (!this.canRecalcHeader) {
return false;
}
@@ -140,7 +140,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..476aa2af20caeb8da293bd9e6c7467e3
}
- protected synchronized void write(final ChunkPos pos, final ByteBuffer data) throws IOException {
+ public synchronized void write(final ChunkPos pos, final ByteBuffer data) throws IOException { // Camellia - Configurable region file format
+ public synchronized void write(final ChunkPos pos, final ByteBuffer data) throws IOException { // Shiroha - Configurable region file format
int offsetIndex = getOffsetIndex(pos);
int offset = this.offsets.get(offsetIndex);
int sectorNumber = getSectorNumber(offset);
@@ -149,7 +149,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..476aa2af20caeb8da293bd9e6c7467e3
@Override
- public final void moonrise$write(final RegionFile regionFile) throws IOException {
+ public final void moonrise$write(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException { // Camellia - Configurable region file format
+ public final void moonrise$write(final moe.monnairealms.camellia.data.RegionFile regionFile) throws IOException { // Shiroha - Configurable region file format
regionFile.write(this.pos, ByteBuffer.wrap(this.buf, 0, this.count));
}
// Paper end - rewrite chunk system
@@ -158,12 +158,12 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..476aa2af20caeb8da293bd9e6c7467e3
}
- synchronized boolean isOversized(int x, int z) {
+ public synchronized boolean isOversized(int x, int z) { // Camellia - Configurable region file format
+ public synchronized boolean isOversized(int x, int z) { // Shiroha - Configurable region file format
return this.oversized[getChunkIndex(x, z)] == 1;
}
- synchronized void setOversized(int x, int z, boolean oversized) throws IOException {
+ public synchronized void setOversized(int x, int z, boolean oversized) throws IOException { // Camellia - Configurable region file format
+ public synchronized void setOversized(int x, int z, boolean oversized) throws IOException { // Shiroha - Configurable region file format
final int offset = getChunkIndex(x, z);
boolean previous = this.oversized[offset] == 1;
this.oversized[offset] = (byte) (oversized ? 1 : 0);
@@ -172,7 +172,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..476aa2af20caeb8da293bd9e6c7467e3
}
- synchronized net.minecraft.nbt.CompoundTag getOversizedData(int x, int z) throws IOException {
+ public synchronized net.minecraft.nbt.CompoundTag getOversizedData(int x, int z) throws IOException { // Camellia - Configurable region file format
+ public synchronized net.minecraft.nbt.CompoundTag getOversizedData(int x, int z) throws IOException { // Shiroha - Configurable region file format
Path file = getOversizedFile(x, z);
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new java.util.zip.InflaterInputStream(Files.newInputStream(file))))) {
return net.minecraft.nbt.NbtIo.read((java.io.DataInput) out);
@@ -185,7 +185,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public static final String ANVIL_EXTENSION = ".mca";
private static final int MAX_CACHE_SIZE = 256;
- private final Long2ObjectLinkedOpenHashMap<RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>();
+ private final Long2ObjectLinkedOpenHashMap<moe.monnairealms.camellia.data.RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>(); // Camellia - Configurable region file format
+ private final Long2ObjectLinkedOpenHashMap<moe.monnairealms.camellia.data.RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>(); // Shiroha - Configurable region file format
private final RegionStorageInfo info;
private final Path folder;
private final boolean sync;
@@ -194,7 +194,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public static ChunkPos getRegionFileCoordinates(Path file) {
String fileName = file.getFileName().toString();
- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
+ if (!fileName.startsWith("r.") || !fileName.endsWith(getExtensionName())) { // Camellia - Configurable region file format
+ if (!fileName.startsWith("r.") || !fileName.endsWith(getExtensionName())) { // Shiroha - Configurable region file format
return null;
}
@@ -203,9 +203,9 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
private final it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet nonExistingRegionFiles = new it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet();
private static String getRegionFileName(final int chunkX, final int chunkZ) {
- return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + ".mca";
+ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + getExtensionName(); // Camellia - Configurable region file format
+ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + getExtensionName(); // Shiroha - Configurable region file format
}
+ // Camellia start - Configurable region file format
+ // Shiroha start - Configurable region file format
+ public static moe.monnairealms.camellia.data.RegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
+ final moe.monnairealms.camellia.enums.EnumRegionFormat regionFormat = moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat;
+ final String fullFileName = filePath.getFileName().toString();
@@ -228,7 +228,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
+ public static String getExtensionName() {
+ return "." + moe.monnairealms.camellia.config.modules.function.RegionFormatConfig.regionFormat.getArgument();
+ }
+ // Camellia end
+ // Shiroha end
private boolean doesRegionFilePossiblyExist(final long position) {
synchronized (this.nonExistingRegionFiles) {
@@ -237,17 +237,17 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
@Override
- public synchronized final RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) {
+ public synchronized final moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) { // Camellia - Configurable region file format
+ public synchronized final moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) { // Shiroha - Configurable region file format
return this.regionCache.getAndMoveToFirst(ChunkPos.pack(chunkX >> REGION_SHIFT, chunkZ >> REGION_SHIFT));
}
@Override
- public synchronized final RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException {
+ public synchronized final moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException { // Camellia - Configurable region file format
+ public synchronized final moe.monnairealms.camellia.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException { // Shiroha - Configurable region file format
final long key = ChunkPos.pack(chunkX >> REGION_SHIFT, chunkZ >> REGION_SHIFT);
- RegionFile ret = this.regionCache.getAndMoveToFirst(key);
+ moe.monnairealms.camellia.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Camellia - Configurable region file format
+ moe.monnairealms.camellia.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Shiroha - Configurable region file format
if (ret != null) {
return ret;
}
@@ -256,7 +256,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
FileUtil.createDirectoriesSafe(this.folder);
- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync); // Camellia - Configurable region file format
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync); // Shiroha - Configurable region file format
this.regionCache.putAndMoveToFirst(key, ret);
@@ -265,7 +265,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
- final RegionFile regionFile = this.getRegionFile(pos);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.getRegionFile(pos); // Camellia - Configurable region file format
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.getRegionFile(pos); // Shiroha - Configurable region file format
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
// (and, the regionfile parameter is unused for writing until the write call)
@@ -274,7 +274,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) {
- final RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Camellia - Configurable region file format
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Shiroha - Configurable region file format
if (regionFile != null) {
regionFile.clear(pos);
} // else: didn't exist
@@ -283,7 +283,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final int chunkX, final int chunkZ
) throws IOException {
- final RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Camellia - Configurable region file format
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Shiroha - Configurable region file format
final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ));
@@ -292,7 +292,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
final ChunkPos headerChunkPos = SerializableChunkData.getChunkCoordinate(ret);
- final RegionFile regionFile = this.getRegionFile(pos);
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.getRegionFile(pos); // Camellia - Configurable region file format
+ final moe.monnairealms.camellia.data.RegionFile regionFile = this.getRegionFile(pos); // Shiroha - Configurable region file format
if (regionFile.getRecalculateCount() != readData.recalculateCount()) {
return null;
@@ -301,7 +301,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
// Paper end - rewrite chunk system
// Paper start - rewrite chunk system
- public RegionFile getRegionFile(ChunkPos pos) throws IOException {
+ public moe.monnairealms.camellia.data.RegionFile getRegionFile(ChunkPos pos) throws IOException { // Camellia - Configurable region file format
+ public moe.monnairealms.camellia.data.RegionFile getRegionFile(ChunkPos pos) throws IOException { // Shiroha - Configurable region file format
return this.getRegionFile(pos, false);
}
// Paper end - rewrite chunk system
@@ -310,7 +310,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
}
- @org.jetbrains.annotations.Contract("_, false -> !null") private @Nullable RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit
+ @org.jetbrains.annotations.Contract("_, false -> !null") private moe.monnairealms.camellia.data.RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit // Camellia - Configurable region file format
+ @org.jetbrains.annotations.Contract("_, false -> !null") private moe.monnairealms.camellia.data.RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit // Shiroha - Configurable region file format
// Paper start - rewrite chunk system
if (existingOnly) {
return this.moonrise$getRegionFileIfExists(pos.x(), pos.z());
@@ -319,7 +319,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
final long key = ChunkPos.pack(pos.x() >> REGION_SHIFT, pos.z() >> REGION_SHIFT);
- RegionFile ret = this.regionCache.getAndMoveToFirst(key);
+ moe.monnairealms.camellia.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Camellia - Configurable region file format
+ moe.monnairealms.camellia.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Shiroha - Configurable region file format
if (ret != null) {
return ret;
}
@@ -328,7 +328,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
FileUtil.createDirectoriesSafe(this.folder);
- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync); // Camellia - Configurable region file format
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync); // Shiroha - Configurable region file format
this.regionCache.putAndMoveToFirst(key, ret);
@@ -337,7 +337,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
}
- private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException {
+ private static CompoundTag readOversizedChunk(moe.monnairealms.camellia.data.RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Camellia - Configurable region file format
+ private static CompoundTag readOversizedChunk(moe.monnairealms.camellia.data.RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Shiroha - Configurable region file format
synchronized (regionfile) {
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x(), chunkCoordinate.z());
@@ -346,7 +346,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public @Nullable CompoundTag read(final ChunkPos pos) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
- RegionFile region = this.getRegionFile(pos, true);
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, true); // Camellia - Configurable region file format
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, true); // Shiroha - Configurable region file format
if (region == null) {
return null;
}
@@ -355,7 +355,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public void scanChunk(final ChunkPos pos, final StreamTagVisitor scanner) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
- RegionFile region = this.getRegionFile(pos, true);
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, true); // Camellia - Configurable region file format
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, true); // Shiroha - Configurable region file format
if (region == null) {
return;
}
@@ -364,7 +364,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
public void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException {
if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) {
- RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system // Camellia - Configurable region file format
+ moe.monnairealms.camellia.data.RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system // Shiroha - Configurable region file format
// Paper start - rewrite chunk system
if (region == null) {
// if the RegionFile doesn't exist, no point in deleting from it
@@ -373,7 +373,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
- for (final RegionFile regionFile : this.regionCache.values()) {
+ for (final moe.monnairealms.camellia.data.RegionFile regionFile : this.regionCache.values()) { // Camellia - Configurable region file format
+ for (final moe.monnairealms.camellia.data.RegionFile regionFile : this.regionCache.values()) { // Shiroha - Configurable region file format
try {
regionFile.close();
} catch (final IOException ex) {
@@ -382,7 +382,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..cc9913016c6d985644f8af47986db770
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
- for (final RegionFile regionFile : this.regionCache.values()) {
+ for (final moe.monnairealms.camellia.data.RegionFile regionFile : this.regionCache.values()) { // Camellia - Configurable region file format
+ for (final moe.monnairealms.camellia.data.RegionFile regionFile : this.regionCache.values()) { // Shiroha - Configurable region file format
try {
regionFile.flush();
} catch (final IOException ex) {
@@ -14,10 +14,10 @@ index fbe0ef19bfabfc42d9e0e08e17b08159321b3804..4c7aa11f5640e959271afd6bbae9b0ba
- int selectX = amountX < 1.0 ? Mth.floor(worldBorder.getCenterX()) : (int)Mth.floor((amountX + 1.0) * random.nextDouble() + selectMinX);
- int selectZ = amountZ < 1.0 ? Mth.floor(worldBorder.getCenterZ()) : (int)Mth.floor((amountZ + 1.0) * random.nextDouble() + selectMinZ);
+ // Camellia start - Correct player respawn place
+ // Shiroha start - Correct player respawn place
+ int selectX = amountX < 0.0 ? Mth.floor(worldBorder.getCenterX()) : (int)Mth.floor(amountX * random.nextDouble() + selectMinX);
+ int selectZ = amountZ < 0.0 ? Mth.floor(worldBorder.getCenterZ()) : (int)Mth.floor(amountZ * random.nextDouble() + selectMinZ);
+ // Camellia end - Correct player respawn place
+ // Shiroha end - Correct player respawn place
return new BlockPos(selectX, 0, selectZ);
}
@@ -25,7 +25,7 @@ index fbe0ef19bfabfc42d9e0e08e17b08159321b3804..4c7aa11f5640e959271afd6bbae9b0ba
}
private static BlockPos findSpawnAround(ServerLevel world, BlockPos selected) {
+ // Camellia start - Correct player respawn place
+ // Shiroha start - Correct player respawn place
+ BlockPos inChunk = PlayerSpawnFinder.getLevelRespawnPos(world, selected.getX(), selected.getZ());
+ if (inChunk != null) {
+ AABB checkVolume = PlayerSpawnFinder.PLAYER_DIMENSIONS.makeBoundingBox((double)inChunk.getX() + 0.5, (double)inChunk.getY(), (double)inChunk.getZ() + 0.5);
@@ -34,12 +34,12 @@ index fbe0ef19bfabfc42d9e0e08e17b08159321b3804..4c7aa11f5640e959271afd6bbae9b0ba
+ return inChunk;
+ }
+ }
+ // Camellia end - Correct player respawn place
+ // Shiroha end - Correct player respawn place
// try hard to find, so that we don't attempt another chunk load
for (int dz = -SPAWN_RADIUS_SELECTION_SEARCH; dz <= SPAWN_RADIUS_SELECTION_SEARCH; ++dz) {
for (int dx = -SPAWN_RADIUS_SELECTION_SEARCH; dx <= SPAWN_RADIUS_SELECTION_SEARCH; ++dx) {
- BlockPos inChunk = PlayerSpawnFinder.getLevelRespawnPos(world, selected.getX() + dx, selected.getZ() + dz);
+ inChunk = PlayerSpawnFinder.getLevelRespawnPos(world, selected.getX() + dx, selected.getZ() + dz); // Camellia - Correct player respawn place
+ inChunk = PlayerSpawnFinder.getLevelRespawnPos(world, selected.getX() + dx, selected.getZ() + dz); // Shiroha - Correct player respawn place
if (inChunk == null) {
continue;
}
@@ -48,7 +48,7 @@ index fbe0ef19bfabfc42d9e0e08e17b08159321b3804..4c7aa11f5640e959271afd6bbae9b0ba
if (newLevel.dimension() == lastDimension) {
- this.connection.internalTeleport(PositionMoveRotation.of(transition), transition.relatives()); // CraftBukkit
+ this.connection.internalTeleport(PositionMoveRotation.of(transition), transition.relatives()); // CraftBukkit // Camellia - Correct player respawn place
+ this.connection.internalTeleport(PositionMoveRotation.of(transition), transition.relatives()); // CraftBukkit // Shiroha - Correct player respawn place
this.connection.resetPosition();
transition.postTeleportTransition().onTransition(this);
return this;
@@ -13,7 +13,7 @@ index d1a045d47dcd12f246d95ecdfc202da357897cbf..8c44de1f7bb80809856fd26fa94d6b94
private ReferenceCountData getReferenceCounterVolatile() {
- return (ReferenceCountData)REFERENCE_COUNTER_HANDLE.get(this);
+ return (ReferenceCountData)REFERENCE_COUNTER_HANDLE.getVolatile(this); // Camellia - Correct CAS get in RegionizedTaskQueue
+ return (ReferenceCountData)REFERENCE_COUNTER_HANDLE.getVolatile(this); // Shiroha - Correct CAS get in RegionizedTaskQueue
}
private ReferenceCountData compareAndExchangeReferenceCounter(final ReferenceCountData expect, final ReferenceCountData update) {
@@ -13,7 +13,7 @@ index 01b3cda3da79abd30860eb33491ac00f9e958767..445858e4d39bd417e1e85bcb9bc7c1a4
private static final int SPAWN_ONE_IN_X_CHANCE = 10;
private static final int NUMBER_OF_SPAWN_ATTEMPTS = 10;
- private final RandomSource random = RandomSource.create();
+ private final RandomSource random = io.papermc.paper.threadedregions.util.ThreadLocalRandomSource.INSTANCE; // Camellia - Correct thread unsafe random sources
+ private final RandomSource random = io.papermc.paper.threadedregions.util.ThreadLocalRandomSource.INSTANCE; // Shiroha - Correct thread unsafe random sources
private final SavedDataStorage savedDataStorage;
// Folia - moved to global data
@@ -26,7 +26,7 @@ index 22b9f70f76ff8f592359e958fa439e9806a29fcc..45fcc35a3e8c4b80b53c96dc810bd51f
public float oRot;
public float tRot;
- private static final RandomSource RANDOM = RandomSource.create();
+ private static final RandomSource RANDOM = io.papermc.paper.threadedregions.util.ThreadLocalRandomSource.INSTANCE; // Camellia - Correct thread unsafe random sources
+ private static final RandomSource RANDOM = io.papermc.paper.threadedregions.util.ThreadLocalRandomSource.INSTANCE; // Shiroha - Correct thread unsafe random sources
private @Nullable Component name;
public EnchantingTableBlockEntity(final BlockPos worldPosition, final BlockState blockState) {
@@ -14,7 +14,7 @@ index d5506bfc84912ec50cd5391225b9b5291435d3aa..994c069b0bcb8f0f1d4269d7a74d6fe7
this.applyEffectsFromBlocks();
if (this.portalProcess != null && this.portalProcess.isInsidePortalThisTick()) {
- this.handlePortal();
+ if (this.handlePortal()) return; // Camellia - Correct portal logic of some projectile entities (Should not be ticking anymore after portal logics)
+ if (this.handlePortal()) return; // Shiroha - Correct portal logic of some projectile entities (Should not be ticking anymore after portal logics)
}
if (hitResult != null && this.isAlive() && hitResult.getType() != HitResult.Type.MISS) {
@@ -27,7 +27,7 @@ index 88c2f0f927bd8376522eb9aed184abd6f09230f6..e54267ecf448a1b7fd6c433afba2d7ee
new ClipContext(originalPosition, originalPosition.add(movement), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)
);
- this.stepMoveAndHit(blockHitResult);
+ if (this.stepMoveAndHit(blockHitResult)) return; // Camellia - Correct portal logic of some projectile entities (Should not be ticking anymore after portal logics)
+ if (this.stepMoveAndHit(blockHitResult)) return; // Shiroha - Correct portal logic of some projectile entities (Should not be ticking anymore after portal logics)
} else {
this.setPos(originalPosition.add(movement));
this.applyEffectsFromBlocks();
@@ -36,7 +36,7 @@ index 88c2f0f927bd8376522eb9aed184abd6f09230f6..e54267ecf448a1b7fd6c433afba2d7ee
}
- private void stepMoveAndHit(final BlockHitResult blockHitResult) {
+ private boolean stepMoveAndHit(final BlockHitResult blockHitResult) { // Camellia - Correct portal logic of some projectile entities
+ private boolean stepMoveAndHit(final BlockHitResult blockHitResult) { // Shiroha - Correct portal logic of some projectile entities
while (this.isAlive()) {
Vec3 initialPosition = this.position();
ArrayList<EntityHitResult> entitiesHit = new ArrayList<>(this.findHitEntities(initialPosition, blockHitResult.getLocation()));
@@ -45,7 +45,7 @@ index 88c2f0f927bd8376522eb9aed184abd6f09230f6..e54267ecf448a1b7fd6c433afba2d7ee
this.applyEffectsFromBlocks(initialPosition, nextLocation);
if (this.portalProcess != null && this.portalProcess.isInsidePortalThisTick()) {
- this.handlePortal();
+ if (this.handlePortal()) return true; // Camellia - Correct portal logic of some projectile entities (Should not be ticking anymore after portal logics)
+ if (this.handlePortal()) return true; // Shiroha - Correct portal logic of some projectile entities (Should not be ticking anymore after portal logics)
}
if (entitiesHit.isEmpty()) {
@@ -53,7 +53,7 @@ index 88c2f0f927bd8376522eb9aed184abd6f09230f6..e54267ecf448a1b7fd6c433afba2d7ee
break;
}
}
+ return false; // Camellia - Correct portal logic of some projectile entities
+ return false; // Shiroha - Correct portal logic of some projectile entities
}
private ProjectileDeflection hitTargetsOrDeflectSelf(final Collection<EntityHitResult> entityHitResults) {
@@ -14,7 +14,7 @@ index 4c7aa11f5640e959271afd6bbae9b0ba3d998abc..625c013e99f41a7d64e301100139f1bf
public Set<DebugSubscription<?>> debugSubscriptions() {
- return !this.server.debugSubscribers().hasRequiredPermissions(this) ? Set.of() : this.requestedDebugSubscriptions;
+ return Set.of(); // Camellia - Do not enable any debug subscriptions
+ return Set.of(); // Shiroha - Do not enable any debug subscriptions
}
public record RespawnConfig(LevelData.RespawnData respawnData, boolean forced) {
@@ -15,7 +15,7 @@ index 53131c1b8d5562f9a1b45dfab4fdbdd37b655139..f4c171c06ac2a3d45c91365781d0789e
// Folia end - region threading
- level.getPoiManager()
- .getType(pos.pos())
+ // Camellia start - Do not load too far poi chunk in poi compete scan
+ // Shiroha start - Do not load too far poi chunk in poi compete scan
+ var blockPosOfJobSite = pos.pos();
+ var sectionPosOfJobSite = net.minecraft.core.SectionPos.asLong(blockPosOfJobSite);
+ var poiManager = level.getPoiManager();
@@ -24,9 +24,9 @@ index 53131c1b8d5562f9a1b45dfab4fdbdd37b655139..f4c171c06ac2a3d45c91365781d0789e
+ // so simply break down if it's not loaded
+ var poiChunk = moe.monnairealms.camellia.config.modules.fixes.POIRangeFixes.doNotCompetePOIIfUnloaded ? poiManager.get(sectionPosOfJobSite) : poiManager.getOrLoad(sectionPosOfJobSite);
+ poiChunk.flatMap(poiSection -> poiSection.getType(blockPosOfJobSite))
+ // Camellia end - Do not load too far poi chunk in poi compete scan
+ /*level.getPoiManager() // Camellia - Do not load too far poi chunk in poi compete scan
+ .getType(pos.pos())*/ // Camellia - Do not load too far poi chunk in poi compete scan
+ // Shiroha end - Do not load too far poi chunk in poi compete scan
+ /*level.getPoiManager() // Shiroha - Do not load too far poi chunk in poi compete scan
+ .getType(pos.pos())*/ // Shiroha - Do not load too far poi chunk in poi compete scan
.ifPresent(
// Paper start - Improve performance of PoiCompetitorScan by unrolling stream
// The previous logic used Stream#reduce to simulate a form of single-iteration bubble sort
@@ -12,9 +12,9 @@ index 3db75ac3f7f111b94178cc29684f24dd55ac5847..39e511061d11039a1027320de624be07
foliaProfiler.startTimer(timerId);
try {
// Folia end - profiler
+ // Camellia start - Entity portal-teleport speed fix
+ // Shiroha start - Entity portal-teleport speed fix
if (isActive) { // Paper - EAR 2
+ if (!(entity instanceof Player) && entity.teleportTickType == 2) { // Camellia - after portal compensate tick
+ if (!(entity instanceof Player) && entity.teleportTickType == 2) { // Shiroha - after portal compensate tick
+ entity.tick();
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
+ // removed from region while ticking
@@ -32,7 +32,7 @@ index 3db75ac3f7f111b94178cc29684f24dd55ac5847..39e511061d11039a1027320de624be07
+ if (entity.handlePortal()) {
+ return;
+ }
+ } else if (!(entity instanceof Player) && entity.teleportTickType == 1) { // Camellia - portal teleport only
+ } else if (!(entity instanceof Player) && entity.teleportTickType == 1) { // Shiroha - portal teleport only
+ entity.teleportTickType++;
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
+ return;
@@ -49,7 +49,7 @@ index 3db75ac3f7f111b94178cc29684f24dd55ac5847..39e511061d11039a1027320de624be07
return;
}
+ }
+ // Camellia end - Entity portal-teleport speed fix
+ // Shiroha end - Entity portal-teleport speed fix
// Folia end - region threading
} else {entity.inactiveTick();} // Paper - EAR 2
profiler.pop();
@@ -61,7 +61,7 @@ index 2a8a7aeddffdfed31cd6e1162c0756986049fbab..a3f473cab6a37e65de233c7f77d9de7c
public long activatedTick = Integer.MIN_VALUE;
public boolean isTemporarilyActive;
public long activatedImmunityTick = Integer.MIN_VALUE;
+ public int teleportTickType = 0; // Camellia - Entity portal-teleport speed fix
+ public int teleportTickType = 0; // Shiroha - Entity portal-teleport speed fix
public void inactiveTick() {
}
@@ -12,11 +12,11 @@ index 3b1c3e84ab24b6e3a0e4d129b3617b393b6d6651..c6ce88fb63e0d40ed011958a1afd36c6
if (Objects.equals(currentTarget, target)) {
return false;
}
+ // Camellia - Fix region threading with entity ai data access
+ // Shiroha - Fix region threading with entity ai data access
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(target)) {
+ return false;
+ }
+ // Camellia end
+ // Shiroha end
LivingEntity originalTarget = target;
target = asValidTarget(target);
if (reason != null) {
@@ -29,7 +29,7 @@ index e097bc1268b4050e3948413c52dea69950858458..977a31f995799cf44fa59cc1db73571e
public void tick(final ServerLevel level, final E body) {
- this.forgetOutdatedMemories();
+ this.forgetOutdatedMemories(body); // Camellia - Fix region threading with entity ai data access
+ this.forgetOutdatedMemories(body); // Shiroha - Fix region threading with entity ai data access
this.tickSensors(level, body);
this.startEachNonRunningBehavior(level, body);
this.tickEachRunningBehavior(level, body);
@@ -39,8 +39,8 @@ index e097bc1268b4050e3948413c52dea69950858458..977a31f995799cf44fa59cc1db73571e
- private void forgetOutdatedMemories() {
- this.memories.values().forEach(MemorySlot::tick);
+ private void forgetOutdatedMemories(E body) { // Camellia - Fix region threading with entity ai data access
+ this.memories.values().forEach(slot -> slot.tick(body)); // Camellia - Fix region threading with entity ai data access
+ private void forgetOutdatedMemories(E body) { // Shiroha - Fix region threading with entity ai data access
+ this.memories.values().forEach(slot -> slot.tick(body)); // Shiroha - Fix region threading with entity ai data access
}
public void stopAll(final ServerLevel level, final E body) {
@@ -52,11 +52,11 @@ index f744ecd20dc70786311a7162b52aa4ceca0717db..c8373151e280764e3175a263d201c078
public static void setWalkAndLookTargetMemories(
final LivingEntity walker, final PositionTracker target, final float speedModifier, final int closeEnoughDistance
) {
+ // Camellia - Fix region threading with entity ai data access
+ // Shiroha - Fix region threading with entity ai data access
+ if (!target.checkThread(walker.level())) {
+ return;
+ }
+ // Camellia end
+ // Shiroha end
WalkTarget walkTarget = new WalkTarget(target, speedModifier, closeEnoughDistance);
walker.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, target);
walker.getBrain().setMemory(MemoryModuleType.WALK_TARGET, walkTarget);
@@ -69,12 +69,12 @@ index 68251875edfa47ac34c64f99510998ad4bbb14b4..cb386eac7855d53c8c1df36305b6b015
return "BlockPosTracker{blockPos=" + this.blockPos + ", centerPosition=" + this.centerPosition + "}";
}
+
+ // Camellia start - Fix region threading with entity ai data access
+ // Shiroha start - Fix region threading with entity ai data access
+ @Override
+ public boolean checkThread(net.minecraft.world.level.Level currOwnedByLevel) {
+ return ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(currOwnedByLevel, this.blockPos);
+ }
+ // Camellia end
+ // Shiroha end
}
diff --git a/net/minecraft/world/entity/ai/behavior/EntityTracker.java b/net/minecraft/world/entity/ai/behavior/EntityTracker.java
index 3ac52b025ac3e1a3f9135b8e593a385a847afe0f..61cdd99e21cf894cf73c1b90c1d4c45a94d222ff 100644
@@ -85,12 +85,12 @@ index 3ac52b025ac3e1a3f9135b8e593a385a847afe0f..61cdd99e21cf894cf73c1b90c1d4c45a
return "EntityTracker for " + this.entity;
}
+
+ // Camellia start - Fix region threading with entity ai data access
+ // Shiroha start - Fix region threading with entity ai data access
+ @Override
+ public boolean checkThread(net.minecraft.world.level.Level currOwnedByLevel) {
+ return ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.entity);
+ }
+ // Camellia end
+ // Shiroha end
}
diff --git a/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
index b40da004b5281a041ee896ae176bfb9c4660f353..1e2a8c2beaec24f04f70baee9eb6a678ce325efa 100644
@@ -100,9 +100,9 @@ index b40da004b5281a041ee896ae176bfb9c4660f353..1e2a8c2beaec24f04f70baee9eb6a678
private boolean tryComputePath(final Mob body, final WalkTarget walkTarget, final long timestamp) {
BlockPos targetPos = walkTarget.getTarget().currentBlockPosition();
+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(body.level(), targetPos)) // Camellia - Fix region threading with entity ai data access
+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(body.level(), targetPos)) // Shiroha - Fix region threading with entity ai data access
this.path = body.getNavigation().createPath(targetPos, 0);
+ else this.path = null; // Camellia - Fix region threading with entity ai data access
+ else this.path = null; // Shiroha - Fix region threading with entity ai data access
this.speedModifier = walkTarget.getSpeedModifier();
Brain<?> brain = body.getBrain();
if (this.reachedTarget(body, walkTarget)) {
@@ -115,7 +115,7 @@ index ce6cf5ecfb190428e3ef9b7dd39c98e3d27a7b9d..2194a77e1746c061e294840ba9a3b8d8
boolean isVisibleBy(final LivingEntity body);
+
+ boolean checkThread(net.minecraft.world.level.Level currOwnedByLevel); // Camellia - Fix region threading with entity ai data access
+ boolean checkThread(net.minecraft.world.level.Level currOwnedByLevel); // Shiroha - Fix region threading with entity ai data access
}
diff --git a/net/minecraft/world/entity/ai/behavior/SleepInBed.java b/net/minecraft/world/entity/ai/behavior/SleepInBed.java
index 16017d819c28b077f732e2ef571eac179d24e323..7d0f7a42c26fe1e236b0b9696b2b962281dd6c70 100644
@@ -125,11 +125,11 @@ index 16017d819c28b077f732e2ef571eac179d24e323..7d0f7a42c26fe1e236b0b9696b2b9622
return false;
}
+ // Camellia - Fix region threading with entity ai data access
+ // Shiroha - Fix region threading with entity ai data access
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(level, target.pos())) {
+ return false;
+ }
+ // Camellia end
+ // Shiroha end
Optional<Long> lastWokenMemory = brain.getMemory(MemoryModuleType.LAST_WOKEN);
if (lastWokenMemory.isPresent()) {
long timeSinceLastWoken = level.getGameTime() - lastWokenMemory.get();
@@ -150,7 +150,7 @@ index 88a89b4c72cc99dc89d3f3cc928b2dfda4125759..af210abbe1d4b75e1c6828cb25181c4c
}
- public void tick() {
+ public void tick(net.minecraft.world.entity.Entity owner) { // Camellia - Fix region threading with entity ai data access
+ public void tick(net.minecraft.world.entity.Entity owner) { // Shiroha - Fix region threading with entity ai data access
if (this.hasValue() && this.canExpire()) {
if (this.hasExpired()) {
this.clear();
@@ -158,7 +158,7 @@ index 88a89b4c72cc99dc89d3f3cc928b2dfda4125759..af210abbe1d4b75e1c6828cb25181c4c
this.timeToLive--;
}
}
+ // Camellia start - Fix region threading with entity ai data access
+ // Shiroha start - Fix region threading with entity ai data access
+ final net.minecraft.world.level.Level ownerLevel = owner.level();
+
+ // type: entity
@@ -192,7 +192,7 @@ index 88a89b4c72cc99dc89d3f3cc928b2dfda4125759..af210abbe1d4b75e1c6828cb25181c4c
+ this.clear();
+ }
+ }
+ // Camellia end
+ // Shiroha end
}
public static <T> MemorySlot<T> create() {
@@ -204,7 +204,7 @@ index e44814cfb6afb594456b8215bd13a92e93de2c85..e0ca242da89d06005da692172a65a373
if (!this.isDone()) {
Vec3 target = this.path.getNextEntityPos(this.mob);
+ // Camellia - Fix region threading with entity ai data access
+ // Shiroha - Fix region threading with entity ai data access
+ if (moe.monnairealms.camellia.config.modules.fixes.PathfindingFixesConfig.breakDownPathfindingWhenOutOfRegion) {
+ // we assume that:
+ // 1. The code above doesn't touch the 'main thread context' with the position from 'this.path'
@@ -214,7 +214,7 @@ index e44814cfb6afb594456b8215bd13a92e93de2c85..e0ca242da89d06005da692172a65a373
+ return;
+ }
+ }
+ // Camellia end
+ // Shiroha end
this.mob.getMoveControl().setWantedPosition(target.x, target.y, target.z, this.speedModifier);
}
}
@@ -226,7 +226,7 @@ index 2ea1ec39a37899ae1510d0036aa670e758077537..18069d0b38ee08d798edc434875f6b5c
}
}
// Paper end - EntityPathfindEvent
+ // Camellia start - Fix region threading with entity ai data access
+ // Shiroha start - Fix region threading with entity ai data access
+ if (moe.monnairealms.camellia.config.modules.fixes.PathfindingFixesConfig.doNotPathfindToNotOwnedTargets) {
+ // filter the targets not owned by current region
+ targets = new java.util.HashSet<>(targets); // well no idea about how to determine if this should be copied to a modifiable one
@@ -237,7 +237,7 @@ index 2ea1ec39a37899ae1510d0036aa670e758077537..18069d0b38ee08d798edc434875f6b5c
+ return null;
+ }
+ }
+ // Camellia end
+ // Shiroha end
ProfilerFiller profiler = Profiler.get();
profiler.push("pathfind");
BlockPos fromPos = above ? this.mob.blockPosition().above() : this.mob.blockPosition();
@@ -249,7 +249,7 @@ index c3667e7997551e0f5ce63bc6ee890082d1431400..95c93df76eeec7eb3f19380efb1e2876
Optional<GlobalPos> likedNoteblockPos = brain.getMemory(MemoryModuleType.LIKED_NOTEBLOCK_POSITION);
if (likedNoteblockPos.isPresent()) {
GlobalPos position = likedNoteblockPos.get();
+ // Camellia - Fix region threading with entity ai data access
+ // Shiroha - Fix region threading with entity ai data access
+ final Level targetLevel = allay.level().getServer().getLevel(position.dimension());
+ final BlockPos targetPos = position.pos();
+
@@ -258,7 +258,7 @@ index c3667e7997551e0f5ce63bc6ee890082d1431400..95c93df76eeec7eb3f19380efb1e2876
+ brain.eraseMemory(MemoryModuleType.LIKED_NOTEBLOCK_POSITION); // The memory value is not being belong to current tick region anymore
+ return Optional.empty();
+ }
+ // Camellia
+ // Shiroha
if (shouldDepositItemsAtLikedNoteblock(allay, brain, position)) {
return Optional.of(new BlockPosTracker(position.pos().above()));
}
@@ -272,7 +272,7 @@ index d5394ae7ce56555ad21aeafb2d78c291c62e2988..c49b0be376f29d21e81680e48659483f
return this.level().getBlockState(position).is(BlockTags.SNIFFER_DIGGABLE_BLOCK)
- && this.getExploredPositions().noneMatch(explored -> GlobalPos.of(this.level().dimension(), position).equals(explored))
- && Optional.ofNullable(this.getNavigation().createPath(position, 1)).map(Path::canReach).orElse(false);
+ && this.getExploredPositions().noneMatch(explored -> { // Camellia - Fix region threading with entity ai data access
+ && this.getExploredPositions().noneMatch(explored -> { // Shiroha - Fix region threading with entity ai data access
+ // thread checks
+ final Level targetLevel = net.minecraft.server.MinecraftServer.getServer().getLevel(explored.dimension());
+ final BlockPos targetPos = explored.pos();
@@ -282,7 +282,7 @@ index d5394ae7ce56555ad21aeafb2d78c291c62e2988..c49b0be376f29d21e81680e48659483f
+ }
+
+ return GlobalPos.of(this.level().dimension(), position).equals(explored); // Original logic
+ }) // Camellia end
+ }) // Shiroha end
+ && Optional.ofNullable(this.getNavigation().createPath(position, 1)).map(Path::canReach).orElse(false);
}
@@ -12,24 +12,24 @@ index 98034a4c96bf2972316078d3b3a49140921aab50..ba4ee88ada40997759f4650b8d4aa9ec
if (leashUuid.isPresent()) {
Entity leasher = serverLevel.getEntity(leashUuid.get());
if (leasher != null) {
+ // Camellia start - Fix off region leashing
+ // Shiroha start - Fix off region leashing
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(leasher)) {
+ entity.spawnAtLocation(serverLevel, Items.LEAD);
+ entity.setLeashData(null);
+ return;
+ }
+ // Camellia end
+ // Shiroha end
setLeashedTo(entity, leasher, true);
return;
}
} else if (pos.isPresent()) {
+ // Camellia start - Fix off region leashing
+ // Shiroha start - Fix off region leashing
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(serverLevel, pos.get())) {
+ entity.spawnAtLocation(serverLevel, Items.LEAD);
+ entity.setLeashData(null);
+ return;
+ }
+ // Camellia end
+ // Shiroha end
setLeashedTo(entity, LeashFenceKnotEntity.getOrCreateKnot(serverLevel, pos.get()), true);
return;
}
@@ -16,15 +16,15 @@ index 40b4eeb561a91264b9ab6ddc49cb8a93daae84a4..efcf294b523ca6b039eb2544546bf863
@Override
public void disconnectAsync(final net.minecraft.network.DisconnectionDetails disconnectionInfo) {
- if (this.cserver.isPrimaryThread()) {
+ if (io.papermc.paper.threadedregions.RegionizedServer.isGlobalTickThread()) { // Camellia - Fix unpatched task returning of ServerConfigurationPacketListenerImpl#disconnectAsync
+ if (io.papermc.paper.threadedregions.RegionizedServer.isGlobalTickThread()) { // Shiroha - Fix unpatched task returning of ServerConfigurationPacketListenerImpl#disconnectAsync
this.disconnect(disconnectionInfo);
return;
}
this.connection.setReadOnly();
- this.server.scheduleOnMain(() -> {
+ // this.server.scheduleOnMain(() -> { // Camellia - Fix unpatched task returning of ServerConfigurationPacketListenerImpl#disconnectAsync
+ io.papermc.paper.threadedregions.RegionizedServer.getInstance().addTask(() -> { // Camellia - Fix unpatched task returning of ServerConfigurationPacketListenerImpl#disconnectAsync
+ // this.server.scheduleOnMain(() -> { // Shiroha - Fix unpatched task returning of ServerConfigurationPacketListenerImpl#disconnectAsync
+ io.papermc.paper.threadedregions.RegionizedServer.getInstance().addTask(() -> { // Shiroha - Fix unpatched task returning of ServerConfigurationPacketListenerImpl#disconnectAsync
this.disconnect(disconnectionInfo); // Currently you cannot cancel disconnect during the config stage
});
}
@@ -14,7 +14,7 @@ index 625c013e99f41a7d64e301100139f1bf4ee3e2e1..7ae5cd4a30e56c8877ea505287eb66e8
}
- private void checkRidingStatistics(final double dx, final double dy, final double dz) {
+ public void checkRidingStatistics(final double dx, final double dy, final double dz) { // Camellia - Fix riding statics desync - make public
+ public void checkRidingStatistics(final double dx, final double dy, final double dz) { // Shiroha - Fix riding statics desync - make public
if (this.isPassenger() && !didNotMove(dx, dy, dz)) {
int distance = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
Entity vehicle = this.getVehicle();
@@ -26,13 +26,13 @@ index a3f473cab6a37e65de233c7f77d9de7c967fcdd0..1bf85a60b3223c9a44bb3e3d6bffe8eb
}
}
+ // Camellia start - Fix riding statics desync
+ // Shiroha start - Fix riding statics desync
public void adjustRiders(boolean teleport) {
+ this.adjustRiders(teleport, false);
+ }
+
+ public void adjustRiders(boolean teleport, boolean syncStatics) {
+ // Camellia end - Fix riding statics desync
+ // Shiroha end - Fix riding statics desync
java.util.ArrayDeque<EntityTreeNode> queue = new java.util.ArrayDeque<>();
queue.add(this);
@@ -40,17 +40,17 @@ index a3f473cab6a37e65de233c7f77d9de7c967fcdd0..1bf85a60b3223c9a44bb3e3d6bffe8eb
for (EntityTreeNode passenger : passengers) {
queue.add(passenger);
+ // Camellia start - Fix riding statics desync
+ // Shiroha start - Fix riding statics desync
+ final double oldX = passenger.root.getX();
+ final double oldY = passenger.root.getY();
+ final double oldZ = passenger.root.getZ();
+ // Camellia end - Fix riding statics desync
+ // Shiroha end - Fix riding statics desync
curr.root.positionRider(passenger.root, teleport ? Entity::snapTo : Entity::setPos);
+ // Camellia start - Fix riding statics desync
+ // Shiroha start - Fix riding statics desync
+ if (syncStatics && passenger.root instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
+ serverPlayer.checkRidingStatistics(serverPlayer.getX() - oldX, serverPlayer.getY() - oldY, serverPlayer.getZ() - oldZ);
+ }
+ // Camellia end - Fix riding statics desync
+ // Shiroha end - Fix riding statics desync
}
}
}
@@ -58,7 +58,7 @@ index a3f473cab6a37e65de233c7f77d9de7c967fcdd0..1bf85a60b3223c9a44bb3e3d6bffe8eb
public void repositionAllPassengers(boolean teleport) {
- this.makePassengerTree().adjustRiders(teleport);
+ this.makePassengerTree().adjustRiders(teleport, true); // Camellia - Fix riding statics desync
+ this.makePassengerTree().adjustRiders(teleport, true); // Shiroha - Fix riding statics desync
}
protected EntityTreeNode makePassengerTree() {
@@ -13,7 +13,7 @@ index 7ae5cd4a30e56c8877ea505287eb66e8a579d3f8..f22b5fdec6da8bcff9aef3d9fed5dbe6
public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer { // Paper - rewrite chunk system
private static final Logger LOGGER = LogUtils.getLogger();
- public static final long LAST_SAVE_ABSENT = Long.MIN_VALUE; public long lastSave = LAST_SAVE_ABSENT; // Paper // Folia - threaded regions - changed to nanoTime
+ public static final long LAST_SAVE_ABSENT = Long.MIN_VALUE; public long lastSave = System.nanoTime(); // Paper // Folia - threaded regions - changed to nanoTime // Camellia - Fix player auto saving ignores interval
+ public static final long LAST_SAVE_ABSENT = Long.MIN_VALUE; public long lastSave = System.nanoTime(); // Paper // Folia - threaded regions - changed to nanoTime // Shiroha - Fix player auto saving ignores interval
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32;
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10;
private static final int FLY_STAT_RECORDING_SPEED = 25;
@@ -12,7 +12,7 @@ index b31b55f00e2ce1bd6c1011fe852bd1dbb37de524..4e52c3a8887781a2299852c0c0d6f0fd
if (entity instanceof ThrownEnderpearl enderpearl) {
this.addEnderPearl(CoordinateUtils.getChunkKey(enderpearl.chunkPosition()), enderpearl.getId()); // Folia - region threading
}
+ if (entity instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Camellia - Fix dragon part desync
+ if (entity instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Shiroha - Fix dragon part desync
entity.registerScheduler(); // Paper - optimise Folia entity scheduler
}
@@ -24,7 +24,7 @@ index 1bf85a60b3223c9a44bb3e3d6bffe8eb093a50e8..c5a9d380f318f176a2bf5d30a10a6d52
Entity copy = this.getType().create(destination, EntitySpawnReason.DIMENSION_TRAVEL);
copy.restoreFrom(this);
copy.transform(pos, yaw, pitch, velocity);
+ if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Camellia - Fix dragon part desync
+ if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Shiroha - Fix dragon part desync
// vanilla code used to call remove _after_ copying, and some stuff is required to be after copy - so add hook here
// for example, clearing of inventory after switching dimensions
this.postRemoveAfterChangingDimensions();
@@ -37,11 +37,11 @@ index ab921ab4b4cc860abd77744f2bd201013e136e51..cf227919723aeb1d33565787996821a1
}
// Paper end - init expToDrop for already dying spawned dragon
+
+ // Camellia start - Fix dragon part desync
+ // Shiroha start - Fix dragon part desync
+ public void syncDragonPartsAfterTeleportTransform() {
+ for (EnderDragonPart part : this.subEntities) {
+ this.tickPart(part, 0.0, 0.0, 0.0); // offset -> 0.0
+ }
+ }
+ // Camellia end
+ // Shiroha end
}
@@ -13,7 +13,7 @@ index 501a0e89cc7bcfce6793f059b080b38666e0fb64..a5870da96da005ed682bc25eac3af6c7
Entity owner = this.owner != null ? findOwnerIncludingDeadPlayer(serverLevel, this.owner.getUUID()) : null;
if (owner instanceof ServerPlayer serverPlayer
- && !owner.isAlive()
+ && (owner.getBukkitEntity().taskScheduler.isRetired() || serverPlayer.getHealth() <= 0.0D) // Camellia - Fix misbehaved ender pearls when player switched dimension
+ && (owner.getBukkitEntity().taskScheduler.isRetired() || serverPlayer.getHealth() <= 0.0D) // Shiroha - Fix misbehaved ender pearls when player switched dimension
&& !serverPlayer.wonGame
&& serverPlayer.level().getGameRules().get(GameRules.ENDER_PEARLS_VANISH_ON_DEATH)) {
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
@@ -13,7 +13,7 @@ index 223793bea54a483fefc66caa7e07b29ab351c339..9a75c6b38f1cabd4415067d781f6ad49
int orgCount = itemStack.getCount();
// CraftBukkit start - fire PlayerPickupItemEvent
- int canHold = player.getInventory().canHold(itemStack);
+ int canHold = player.hasInfiniteMaterials() ? orgCount : player.getInventory().canHold(itemStack); // Camellia - Fix creative item picking
+ int canHold = player.hasInfiniteMaterials() ? orgCount : player.getInventory().canHold(itemStack); // Shiroha - Fix creative item picking
int remaining = orgCount - canHold;
boolean flyAtPlayer = false; // Paper
@@ -15,7 +15,7 @@ index c5a9d380f318f176a2bf5d30a10a6d528d23bb92..5f7dad51fdca3b85f8ae164b1f58241e
this.moveStartZ = this.getZ();
this.moveVector = delta;
}
+ // Camellia start - Fix high velocity moving issue
+ // Shiroha start - Fix high velocity moving issue
+ // Filter the threads as it may be called by the chunk system worker thread
+ if (moe.monnairealms.camellia.config.modules.fixes.FoliaEntityMovingFixConfig.enabled && ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()){
+ var finalPosition = delta.add(this.position);
@@ -27,7 +27,7 @@ index c5a9d380f318f176a2bf5d30a10a6d528d23bb92..5f7dad51fdca3b85f8ae164b1f58241e
+ }
+ }
+ }
+ // Camellia end
+ // Shiroha end
try {
// Paper end - detailed watchdog information
if (this.noPhysics) {
@@ -39,8 +39,8 @@ index a0eb1f608a99301e0197ab1d1a6fbbb0a0be4ce0..52bcb87e96f7b5997559bd532481f548
public <T extends Entity> void guardEntityTick(final Consumer<T> tick, final T entity) {
try {
tick.accept(entity);
+ } catch (moe.monnairealms.camellia.utils.entity.EntityMoveOutOfRegionException moveOutOfRegionException) { // Camellia - Fix high velocity moving issue
+ // Camellia start - Fix high velocity moving issue
+ } catch (moe.monnairealms.camellia.utils.entity.EntityMoveOutOfRegionException moveOutOfRegionException) { // Shiroha - Fix high velocity moving issue
+ // Shiroha start - Fix high velocity moving issue
+ final Entity ent = moveOutOfRegionException.getEntity();
+ var currPosition = ent.position();
+ var toPosition = moveOutOfRegionException.getMovement().add(currPosition);
@@ -57,7 +57,7 @@ index a0eb1f608a99301e0197ab1d1a6fbbb0a0be4ce0..52bcb87e96f7b5997559bd532481f548
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS,
+ null
+ ));
+ // Camellia end
+ // Shiroha end
} catch (Throwable t) {
// Paper start - Prevent block entity and entity crashes
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", io.papermc.paper.util.MCUtil.getLevelName(entity.level()), entity.getX(), entity.getY(), entity.getZ());
@@ -13,7 +13,7 @@ index 2a64a5b2cf049661fe3f5a22ddfa39979624f5ec..335e9775e0d9a61f0e9641aba691a3bd
}
(useFromRootVehicle ? realFrom.getRootVehicle() : realFrom).teleportAsync(
- ((CraftWorld)loc.getWorld()).getHandle(), pos, null, null, null,
+ ((CraftWorld)loc.getWorld()).getHandle(), pos, yaw, pitch, null, // Camellia - Fix teleport missing original rotation and velocity
+ ((CraftWorld)loc.getWorld()).getHandle(), pos, yaw, pitch, null, // Shiroha - Fix teleport missing original rotation and velocity
cause, teleportFlags, onComplete
);
},
@@ -27,8 +27,8 @@ index 13d7965fd4f99f0848b080349df41f8b1c31a19b..9c5583886ccabb536a519e5a998ed798
Vec3 posFinal = new Vec3(x, y, z);
- Float yawFinal = Float.valueOf(newYRot);
- Float pitchFinal = Float.valueOf(newXRot);
+ Float yawFinal = Float.valueOf(newYRot + victim.getYRot()); // Camellia - Fix teleport missing original rotation and velocity
+ Float pitchFinal = Float.valueOf(newXRot + victim.getXRot()); // Camellia - Fix teleport missing original rotation and velocity
+ Float yawFinal = Float.valueOf(newYRot + victim.getYRot()); // Shiroha - Fix teleport missing original rotation and velocity
+ Float pitchFinal = Float.valueOf(newXRot + victim.getXRot()); // Shiroha - Fix teleport missing original rotation and velocity
victim.getBukkitEntity().taskScheduler.schedule((Entity nmsEntity) -> {
nmsEntity.stopRiding();
nmsEntity.teleportAsync(
@@ -41,7 +41,7 @@ index a5870da96da005ed682bc25eac3af6c771dee851..4672d76ecf926975948135598f554055
entity.teleportAsync(
- checkWorld, to, null, null, null,
+ checkWorld, to, null, null, entity.getDeltaMovement(), // Camellia - Fix teleport missing original rotation and velocity
+ checkWorld, to, null, null, entity.getDeltaMovement(), // Shiroha - Fix teleport missing original rotation and velocity
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL,
// chunk could have been unloaded
Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS | Entity.TELEPORT_FLAG_LOAD_CHUNK,
@@ -13,7 +13,7 @@ index a6ab9cb01f4f49f5f44b6ed324fa6d51139aabb6..7bf49d2c235cb3f6c4cd8de4d127f476
private static final Logger LOGGER = LogUtils.getLogger();
- private static int regionShift = 31;
+ private static int regionShift = ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT; // Camellia - Force clamp grid-exponent to 1~6
+ private static int regionShift = ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT; // Shiroha - Force clamp grid-exponent to 1~6
public static int getRegionChunkShift() {
return regionShift;
@@ -22,8 +22,8 @@ index a6ab9cb01f4f49f5f44b6ed324fa6d51139aabb6..7bf49d2c235cb3f6c4cd8de4d127f476
int gridExponent = config.gridExponent;
gridExponent = Math.max(0, gridExponent);
- gridExponent = Math.min(31, gridExponent);
+ if (gridExponent > ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT) LOGGER.warn("You are using a grid-exponent ({}) which is larger than the ticket lock shift! This would lead to randomly fatal crash !!!, Clamping back to max allowed {}", gridExponent, ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT); // Camellia - Force clamp grid-exponent to 1~6
+ gridExponent = Math.min(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT, gridExponent); // Camellia - Force clamp grid-exponent to 1~6
+ if (gridExponent > ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT) LOGGER.warn("You are using a grid-exponent ({}) which is larger than the ticket lock shift! This would lead to randomly fatal crash !!!, Clamping back to max allowed {}", gridExponent, ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT); // Shiroha - Force clamp grid-exponent to 1~6
+ gridExponent = Math.min(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT, gridExponent); // Shiroha - Force clamp grid-exponent to 1~6
regionShift = gridExponent;
scheduler = new TickRegionScheduler(config.scheduler, tickThreads);
LOGGER.info("Initialised " + config.scheduler + " Folia scheduler with initial " + tickThreads + " target thread(s)");
@@ -15,8 +15,8 @@ index 78e9cf21fb5487e5eeec04e589c2a84c1e6b06af..b01e00de94d8fa45359d3d14a8481287
this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
- this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
- this.server.spark.enableAfterPlugins(this.server); // Paper - spark
+ if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.enableAfterPlugins(this.server); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Shiroha - Force disable builtin spark
+ if (false) this.server.spark.enableAfterPlugins(this.server); // Paper - spark // Shiroha - Force disable builtin spark
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // Paper - reset invalid state for event fire below
io.papermc.paper.plugin.lifecycle.event.LifecycleEventRunner.INSTANCE.callReloadableRegistrarEvent(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, io.papermc.paper.command.brigadier.PaperCommands.INSTANCE, org.bukkit.plugin.Plugin.class, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.INITIAL); // Paper - call commands event for regular plugins
this.server.getCommandMap().registerServerAliases(); // Paper - relocate initial CommandMap#registerServerAliases() call
@@ -25,7 +25,7 @@ index 78e9cf21fb5487e5eeec04e589c2a84c1e6b06af..b01e00de94d8fa45359d3d14a8481287
// CraftBukkit start
if (this.server != null) {
- this.server.spark.disable(); // Paper - spark
+ if (false) this.server.spark.disable(); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.disable(); // Paper - spark // Shiroha - Force disable builtin spark
this.server.disablePlugins();
this.server.waitForAsyncTasksShutdown(); // Paper - Wait for Async Tasks during shutdown
}
@@ -34,7 +34,7 @@ index 78e9cf21fb5487e5eeec04e589c2a84c1e6b06af..b01e00de94d8fa45359d3d14a8481287
this.status = this.buildServerStatus();
- this.server.spark.enableBeforePlugins(); // Paper - spark
+ if (false) this.server.spark.enableBeforePlugins(); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.enableBeforePlugins(); // Paper - spark // Shiroha - Force disable builtin spark
// Folia start - region threading
if (true) {
io.papermc.paper.threadedregions.RegionizedServer.getInstance().init(); // Folia - region threading - only after loading worlds
@@ -43,7 +43,7 @@ index 78e9cf21fb5487e5eeec04e589c2a84c1e6b06af..b01e00de94d8fa45359d3d14a8481287
if (this.emptyTicks >= emptyTickThreshold) {
- this.server.spark.tickStart(); // Paper - spark
+ if (false) this.server.spark.tickStart(); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.tickStart(); // Paper - spark // Shiroha - Force disable builtin spark
if (this.emptyTicks == emptyTickThreshold) {
LOGGER.info("Server empty for {} seconds, pausing", this.pauseWhenEmptySeconds());
this.autoSave();
@@ -52,7 +52,7 @@ index 78e9cf21fb5487e5eeec04e589c2a84c1e6b06af..b01e00de94d8fa45359d3d14a8481287
//this.server.spark.executeMainThreadTasks(); // Paper - spark // Folia - region threading
this.tickConnection();
- this.server.spark.tickEnd(((double)(System.nanoTime() - this.currentTickStart) / 1000000D)); // Paper - spark
+ if (false) this.server.spark.tickEnd(((double)(System.nanoTime() - this.currentTickStart) / 1000000D)); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.tickEnd(((double)(System.nanoTime() - this.currentTickStart) / 1000000D)); // Paper - spark // Shiroha - Force disable builtin spark
return;
}
}
@@ -61,7 +61,7 @@ index 78e9cf21fb5487e5eeec04e589c2a84c1e6b06af..b01e00de94d8fa45359d3d14a8481287
// Folia end - region threading
- this.server.spark.tickStart(); // Paper - spark
+ if (false) this.server.spark.tickStart(); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.tickStart(); // Paper - spark // Shiroha - Force disable builtin spark
new com.destroystokyo.paper.event.server.ServerTickStartEvent((int)region.getCurrentTick()).callEvent(); // Paper - Server Tick Events // Folia - region threading
// Folia start - region threading
if (region != null) {
@@ -70,7 +70,7 @@ index 78e9cf21fb5487e5eeec04e589c2a84c1e6b06af..b01e00de94d8fa45359d3d14a8481287
new com.destroystokyo.paper.event.server.ServerTickEndEvent((int)io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(), ((double)(endTime - startTime) / 1000000D), remaining).callEvent(); // Folia - region ticking
// Paper end - Server Tick Events
- this.server.spark.tickEnd(((double)(endTime - startTime) / 1000000D)); // Paper - spark // Folia - region threading
+ if (false) this.server.spark.tickEnd(((double)(endTime - startTime) / 1000000D)); // Paper - spark // Folia - region threading // Camellia - Force disable builtin spark
+ if (false) this.server.spark.tickEnd(((double)(endTime - startTime) / 1000000D)); // Paper - spark // Folia - region threading // Shiroha - Force disable builtin spark
// Folia - region threading
}
@@ -81,9 +81,9 @@ index 17244a82d7591004a43c013748f3db0507e73d7e..4d4a1475b315dd3cb855443ecd1fa75f
@@ -239,7 +239,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
// Paper end - initialize global and world-defaults configuration
moe.monnairealms.camellia.config.ConfigManager.loadConfigFiles(); // Camellia - Config system framework - load config file
moe.monnairealms.camellia.config.ConfigManager.loadConfigFiles(); // Shiroha - Config system framework - load config file
- this.server.spark.enableEarlyIfRequested(); // Paper - spark
+ if (false) this.server.spark.enableEarlyIfRequested(); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.enableEarlyIfRequested(); // Paper - spark // Shiroha - Force disable builtin spark
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
if (this.convertOldUsers()) {
this.services().nameToIdCache().save(false); // Paper
@@ -92,7 +92,7 @@ index 17244a82d7591004a43c013748f3db0507e73d7e..4d4a1475b315dd3cb855443ecd1fa75f
consoleThread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized
io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
- this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
+ if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Shiroha - Force disable builtin spark
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
@@ -17,8 +17,8 @@ index 95ba821a895c7ea8fffcbf1df2e7b3c174463d9e..1e076d368f2e34b83b94e939ca9856ba
}
- BlockState blockStateBelow = this.level().getBlockState(pos.below());
+ BlockState blockStateBelow = this.level().getBlockStateIfLoaded(pos.below()); // Camellia - Prevent tamable animals check can teleport in an unloaded chunk
+ if (blockStateBelow == null) return false; // Camellia - Prevent tamable animals check can teleport in an unloaded chunk
+ BlockState blockStateBelow = this.level().getBlockStateIfLoaded(pos.below()); // Shiroha - Prevent tamable animals check can teleport in an unloaded chunk
+ if (blockStateBelow == null) return false; // Shiroha - Prevent tamable animals check can teleport in an unloaded chunk
if (!this.canFlyToOwner() && blockStateBelow.getBlock() instanceof LeavesBlock) {
return false;
}
@@ -13,7 +13,7 @@ index 10fa576838c726d026df078eef6c693d14c2cbda..20fa23988efbfb50c664fa48cc823adb
public class PacketProcessor implements AutoCloseable {
private static final Logger LOGGER = LogUtils.getLogger();
- private final Queue<PacketProcessor.ListenerAndPacket<?>> packetsToBeHandled = Queues.newConcurrentLinkedQueue();
+ private final Queue<PacketProcessor.ListenerAndPacket<?>> packetsToBeHandled = new ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue<>(); // Camellia - Replace packet processing queue with mt-queue
+ private final Queue<PacketProcessor.ListenerAndPacket<?>> packetsToBeHandled = new ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue<>(); // Shiroha - Replace packet processing queue with mt-queue
private final Thread runningThread;
private boolean closed;
@@ -12,7 +12,7 @@ index 40f54536422fa38bd84017fc634808016b4de58b..d0dff5850717bd083b7a29104a61754c
}
}
// Paper end - Optimize network
+ // Camellia start - async protocol switcher
+ // Shiroha start - async protocol switcher
+ public <T extends PacketListener> void setupInboundProtocolAsync(
+ ProtocolInfo<T> protocol,
+ T packetListener,
@@ -133,7 +133,7 @@ index 40f54536422fa38bd84017fc634808016b4de58b..d0dff5850717bd083b7a29104a61754c
+ writeTask.run();
+ }
+ }
+ // Camellia end
+ // Shiroha end
+
}
diff --git a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
@@ -145,9 +145,9 @@ index efcf294b523ca6b039eb2544546bf863ba717749..343c98fb35eb4cb736d26f67a11c00ef
PacketUtils.ensureRunningOnSameThread(packet, this, this.server.packetProcessor());
this.finishCurrentTask(JoinWorldTask.TYPE);
- this.connection.setupOutboundProtocol(GameProtocols.CLIENTBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())));
+ // this.connection.setupOutboundProtocol(GameProtocols.CLIENTBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess()))); // Camellia - Async protocol switch - move down
+ // this.connection.setupOutboundProtocol(GameProtocols.CLIENTBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess()))); // Shiroha - Async protocol switch - move down
+ Runnable afterSwitch = () -> { // Camellia - Async protocol switch
+ Runnable afterSwitch = () -> { // Shiroha - Async protocol switch
try {
PlayerList playerList = this.server.getPlayerList();
if (playerList.getPlayer(this.gameProfile.id()) != null) {
@@ -155,7 +155,7 @@ index efcf294b523ca6b039eb2544546bf863ba717749..343c98fb35eb4cb736d26f67a11c00ef
LOGGER.error("Couldn't place player in world", e);
this.disconnect(DISCONNECT_REASON_INVALID_DATA);
}
+ // Camellia start - Async protocol switch
+ // Shiroha start - Async protocol switch
+ };
+ if (!moe.monnairealms.camellia.config.modules.optimizations.AsyncProtocolChangeConfig.enabled) {
+ this.connection.setupOutboundProtocol(GameProtocols.CLIENTBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())));
@@ -166,7 +166,7 @@ index efcf294b523ca6b039eb2544546bf863ba717749..343c98fb35eb4cb736d26f67a11c00ef
+ io.papermc.paper.threadedregions.RegionizedServer.getInstance().addTask(afterSwitch);
+ }, false); // we will start auto read once we set up inbound handler at placeNewPlayer in PlayerList
+ }
+ // Camellia end
+ // Shiroha end
}
@Override
@@ -178,13 +178,13 @@ index eda7e765c7c2ffee305edc81e0c7a6b1e5bfa18d..4c9ea818be83ed3c4dacc762f4d0e8c0
} // Folia end - rewrite login process - move connection ownership to global region
this.waitingForSwitchToConfig = true; // Folia - rewrite login process - fix bad ordering of this field write - moved down
this.send(ClientboundStartConfigurationPacket.INSTANCE);
+ if (!moe.monnairealms.camellia.config.modules.optimizations.AsyncProtocolChangeConfig.enabled) { // Camellia - Async protocol switch
+ if (!moe.monnairealms.camellia.config.modules.optimizations.AsyncProtocolChangeConfig.enabled) { // Shiroha - Async protocol switch
this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND);
+ // Camellia start - Async protcol switch
+ // Shiroha start - Async protcol switch
+ } else {
+ this.connection.setupOutboundProtocolAsync(ConfigurationProtocols.CLIENTBOUND, null, true);
+ }
+ // Camellia end
+ // Shiroha end
}
@Override
@@ -192,15 +192,15 @@ index eda7e765c7c2ffee305edc81e0c7a6b1e5bfa18d..4c9ea818be83ed3c4dacc762f4d0e8c0
}
final ServerConfigurationPacketListenerImpl listener = new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation())); // Paper
+ if (!moe.monnairealms.camellia.config.modules.optimizations.AsyncProtocolChangeConfig.enabled) { // Camellia - Async protocol switch
+ if (!moe.monnairealms.camellia.config.modules.optimizations.AsyncProtocolChangeConfig.enabled) { // Shiroha - Async protocol switch
this.connection
.setupInboundProtocol(
ConfigurationProtocols.SERVERBOUND,
listener // Paper
);
new io.papermc.paper.event.connection.configuration.PlayerConnectionReconfigureEvent(listener.paperConnection).callEvent(); // Paper
+ } // Camellia - Async protocol switch - add "{"
+ // Camellia start - Async protocol switch - move up
+ } // Shiroha - Async protocol switch - add "{"
+ // Shiroha start - Async protocol switch - move up
+ else
+ this.connection.setupInboundProtocolAsync(
+ ConfigurationProtocols.SERVERBOUND,
@@ -210,8 +210,8 @@ index eda7e765c7c2ffee305edc81e0c7a6b1e5bfa18d..4c9ea818be83ed3c4dacc762f4d0e8c0
+ },
+ true
+ );
+ // Camellia end
+ // new io.papermc.paper.event.connection.configuration.PlayerConnectionReconfigureEvent(listener.paperConnection).callEvent(); // Paper // Camellia - Async protocol switch - move up
+ // Shiroha end
+ // new io.papermc.paper.event.connection.configuration.PlayerConnectionReconfigureEvent(listener.paperConnection).callEvent(); // Paper // Shiroha - Async protocol switch - move up
}
@Override
@@ -224,15 +224,15 @@ index f2329d1a9d9d4bf4c9d771e25e54f2f9ef65a76c..7de3bbecea2f11e4e1cb65408729f346
net.minecraft.network.protocol.PacketUtils.ensureRunningOnSameThread(packet, this, this.server.packetProcessor()); // CraftBukkit
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet");
- this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND);
+ /*this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); // Camellia - Async protocol switch - Rewrite
+ /*this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); // Shiroha - Async protocol switch - Rewrite
CommonListenerCookie cookie = CommonListenerCookie.createInitial(Objects.requireNonNull(this.authenticatedProfile), this.transferred);
ServerConfigurationPacketListenerImpl configPacketListener = new ServerConfigurationPacketListenerImpl(this.server, this.connection, cookie);
this.connection.setupInboundProtocol(ConfigurationProtocols.SERVERBOUND, configPacketListener);
configPacketListener.startConfiguration();
- this.state = ServerLoginPacketListenerImpl.State.ACCEPTED;
+ this.state = ServerLoginPacketListenerImpl.State.ACCEPTED;*/ // Camellia - Async protocol switch - Rewrite
+ this.state = ServerLoginPacketListenerImpl.State.ACCEPTED;*/ // Shiroha - Async protocol switch - Rewrite
+
+ // Camellia start - Async protocol switch
+ // Shiroha start - Async protocol switch
+ CommonListenerCookie cookie = CommonListenerCookie.createInitial(Objects.requireNonNull(this.authenticatedProfile), this.transferred);
+ ServerConfigurationPacketListenerImpl configPacketListener = new ServerConfigurationPacketListenerImpl(this.server, this.connection, cookie);
+
@@ -248,7 +248,7 @@ index f2329d1a9d9d4bf4c9d771e25e54f2f9ef65a76c..7de3bbecea2f11e4e1cb65408729f346
+ this.connection.setupInboundProtocolAsync(ConfigurationProtocols.SERVERBOUND, configPacketListener, () -> {
+ this.connection.setupOutboundProtocolAsync(ConfigurationProtocols.CLIENTBOUND, afterSwitch, true); // start auto read when everything is ready
+ }, false); // we will resume auto reading once the outbound protocol is also setup
+ // Camellia end
+ // Shiroha end
}
@Override
@@ -260,11 +260,11 @@ index e7579a9873362317dd82b63306cf650af9472574..9e90197b96fcac958c5073ca8f560e77
// only after setting the connection listener to game type, add the connection to this regions list
level.getCurrentWorldData().connections.add(connection);
// Folia end - rewrite login process
+ if (!moe.monnairealms.camellia.config.modules.optimizations.AsyncProtocolChangeConfig.enabled) { // Camellia - Async protocol switch // we will run async switch once these main thread logics became done
+ if (!moe.monnairealms.camellia.config.modules.optimizations.AsyncProtocolChangeConfig.enabled) { // Shiroha - Async protocol switch // we will run async switch once these main thread logics became done
connection.setupInboundProtocol(
GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess()), playerConnection), playerConnection
);
+ } // Camellia - Async protocol switch
+ } // Shiroha - Async protocol switch
playerConnection.suspendFlushing();
GameRules gameRules = level.getGameRules();
boolean immediateRespawn = gameRules.get(GameRules.IMMEDIATE_RESPAWN);
@@ -272,7 +272,7 @@ index e7579a9873362317dd82b63306cf650af9472574..9e90197b96fcac958c5073ca8f560e77
);
}
// Paper end - Send empty chunk
+ // Camellia start - Async protocol switch
+ // Shiroha start - Async protocol switch
+ if (moe.monnairealms.camellia.config.modules.optimizations.AsyncProtocolChangeConfig.enabled) {
+ // auto read will be enabled once the async switch is done
+ connection.setupInboundProtocolAsync(
@@ -282,7 +282,7 @@ index e7579a9873362317dd82b63306cf650af9472574..9e90197b96fcac958c5073ca8f560e77
+ true // start auto read which we have disabled in configuration handler
+ );
+ }
+ // Camellia end
+ // Shiroha end
}
public void updateEntireScoreboard(final ServerScoreboard scoreboard, final ServerPlayer player) {
@@ -19,27 +19,27 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
- private static final TextColor SECONDARY = TextColor.color(104, 177, 240);
- private static final TextColor INFORMATION = TextColor.color(145, 198, 243);
- private static final TextColor LIST = TextColor.color(33, 97, 188);
+ private static final TextColor HEADER = TextColor.color(0xcb, 0xa6, 0xf7); // Camellia - Catppuccin Mocha: Mauve
+ private static final TextColor PRIMARY = TextColor.color(0xa6, 0xad, 0xc8); // Camellia - Catppuccin Mocha: Subtext0
+ private static final TextColor SECONDARY = TextColor.color(0xb4, 0xbe, 0xfe); // Camellia - Catppuccin Mocha: Lavender
+ private static final TextColor INFORMATION = TextColor.color(0xcd, 0xd6, 0xf4); // Camellia - Catppuccin Mocha: Text
+ private static final TextColor LIST = TextColor.color(0x74, 0xc7, 0xec); // Camellia - Catppuccin Mocha: Sapphire
+ // Camellia start - prettier /tps output
+ private static final TextColor HEADER = TextColor.color(0xcb, 0xa6, 0xf7); // Shiroha - Catppuccin Mocha: Mauve
+ private static final TextColor PRIMARY = TextColor.color(0xa6, 0xad, 0xc8); // Shiroha - Catppuccin Mocha: Subtext0
+ private static final TextColor SECONDARY = TextColor.color(0xb4, 0xbe, 0xfe); // Shiroha - Catppuccin Mocha: Lavender
+ private static final TextColor INFORMATION = TextColor.color(0xcd, 0xd6, 0xf4); // Shiroha - Catppuccin Mocha: Text
+ private static final TextColor LIST = TextColor.color(0x74, 0xc7, 0xec); // Shiroha - Catppuccin Mocha: Sapphire
+ // Shiroha start - prettier /tps output
+ private static final TextColor MUTED = TextColor.color(0x6c, 0x70, 0x86); // Catppuccin Mocha: Overlay0
+ private static final int DIVIDER_WIDTH = 44;
+ private static final int BAR_SEGMENTS = 20;
+ private static final String[] RANK_ICONS = {"①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨", "⑩"};
+ // Camellia end
+ // Shiroha end
public CommandServerHealth() {
super("tps");
- this.setUsage("/<command> [server/region] [lowest regions to display]");
+ this.setUsage("/<command> [server/region] [lowest regions to display|all]"); // Camellia - document "all" option
+ this.setUsage("/<command> [server/region] [lowest regions to display|all]"); // Shiroha - document "all" option
this.setDescription("Reports information about server health.");
this.setPermission("bukkit.command.tps");
}
+ // Camellia start - prettier /tps output helpers
+ // Shiroha start - prettier /tps output helpers
+ private static Component divider() {
+ // strikethrough spaces render as a solid flat line on every client/font, unlike box-drawing glyphs
+ return Component.text(" ".repeat(DIVIDER_WIDTH), MUTED, TextDecoration.STRIKETHROUGH);
@@ -67,11 +67,11 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
+ .append(Component.text(" ".repeat(BAR_SEGMENTS - filled), MUTED, TextDecoration.STRIKETHROUGH))
+ .build();
+ }
+ // Camellia end
+ // Shiroha end
+
private static Component formatRegionInfo(final String prefix, final double util, final double mspt, final double tps,
final boolean newline) {
+ // Camellia start - use progress bar + dot separators instead of plain "util at ... MSPT at ..." text
+ // Shiroha start - use progress bar + dot separators instead of plain "util at ... MSPT at ..." text
return Component.text()
- .append(Component.text(prefix, PRIMARY, TextDecoration.BOLD))
- .append(Component.text(ONE_DECIMAL_PLACES.get().format(util * 100.0), CommandUtil.getUtilisationColourRegion(util)))
@@ -91,11 +91,11 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
+ .append(Component.text(TWO_DECIMAL_PLACES.get().format(tps) + " tps", CommandUtil.getColourForTPS(tps)))
+ .append(Component.text(newline ? "\n" : "", PRIMARY))
+ .build();
+ // Camellia end
+ // Shiroha end
}
private static Component formatRegionStats(final TickRegions.RegionStats stats, final boolean newline) {
+ // Camellia start - add "·" separators for readability
+ // Shiroha start - add "·" separators for readability
return Component.text()
- .append(Component.text("Chunks: ", PRIMARY))
- .append(Component.text(NO_DECIMAL_PLACES.get().format((long)stats.getChunkCount()), INFORMATION))
@@ -111,7 +111,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
+ .append(Component.text(" · Entities: ", PRIMARY))
+ .append(Component.text(NO_DECIMAL_PLACES.get().format((long)stats.getEntityCount()) + (newline ? "\n" : ""), INFORMATION))
+ .build();
+ // Camellia end
+ // Shiroha end
}
private static boolean executeRegion(final CommandSender sender, final String commandLabel, final String[] args) {
@@ -125,7 +125,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
final int yLoc = 80;
final String location = "[w:'" + world.getWorld().getName() + "'," + centerBlockX + "," + yLoc + "," + centerBlockZ + "]";
+ // Camellia start - prettier /tps region output
+ // Shiroha start - prettier /tps region output
final Component line = Component.text()
- .append(Component.text("Region around block ", PRIMARY))
- .append(Component.text(location, INFORMATION))
@@ -157,7 +157,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
+ )
+
+ .build();
+ // Camellia end
+ // Shiroha end
sender.sendMessage(line);
@@ -165,7 +165,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
}
private static boolean executeServer(final CommandSender sender, final String commandLabel, final String[] args) {
+ // Camellia start - "all" lists every tick region instead of just the top N by utilisation
+ // Shiroha start - "all" lists every tick region instead of just the top N by utilisation
+ final boolean showAllRegions = args.length >= 2 && args[1].equalsIgnoreCase("all");
final int lowestRegionsCount;
- if (args.length < 2) {
@@ -181,7 +181,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
return true;
}
}
+ // Camellia end
+ // Shiroha end
final List<ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData>> regions =
- new ArrayList<>();
@@ -193,7 +193,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
final double loadRate = ca.spottedleaf.moonrise.patches.chunk_system.scheduling.task.ChunkFullTask.loadRate(currTime);
totalUtil += globalTickReport.utilisation();
+ final double overallFraction = maxThreadCount > 0 ? (totalUtil / maxThreadCount) : 0.0; // Camellia - overall load fraction for progress bar
+ final double overallFraction = maxThreadCount > 0 ? (totalUtil / maxThreadCount) : 0.0; // Shiroha - overall load fraction for progress bar
tpsByRegion.sort(null);
if (!tpsByRegion.isEmpty()) {
@@ -211,10 +211,10 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
if (sender instanceof Player) {
- lowestRegionsBuilder.append(Component.text(" Click to teleport\n", SECONDARY));
+ lowestRegionsBuilder.append(Component.text(" Click to teleport\n", SECONDARY, TextDecoration.ITALIC)); // Camellia - restyle hint text
+ lowestRegionsBuilder.append(Component.text(" Click to teleport\n", SECONDARY, TextDecoration.ITALIC)); // Shiroha - restyle hint text
}
- for (int i = 0, len = Math.min(lowestRegionsCount, regionsBelowThreshold.size()); i < len; ++i) {
+ for (int i = 0, len = showAllRegions ? regionsBelowThreshold.size() : Math.min(lowestRegionsCount, regionsBelowThreshold.size()); i < len; ++i) { // Camellia - support "all"
+ for (int i = 0, len = showAllRegions ? regionsBelowThreshold.size() : Math.min(lowestRegionsCount, regionsBelowThreshold.size()); i < len; ++i) { // Shiroha - support "all"
final ObjectObjectImmutablePair<ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData>, TickData.TickReportData>
- pair = regionsBelowThreshold.get(i);
+ pair = regionsBelowThreshold.get(i);
@@ -230,7 +230,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
final int yLoc = 80;
final String location = "[w:'" + world.getWorld().getName() + "'," + centerBlockX + "," + yLoc + "," + centerBlockZ + "]";
+ // Camellia start - prettier /tps region list entries
+ // Shiroha start - prettier /tps region list entries
final Component line = Component.text()
- .append(Component.text(" - ", LIST, TextDecoration.BOLD))
- .append(Component.text("Region around block ", PRIMARY))
@@ -251,7 +251,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
-
- .clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, Payload.string("/minecraft:execute as @s in " + world.getWorld().getKey().toString() + " run tp " + centerBlockX + ".5 " + yLoc + " " + centerBlockZ + ".5")))
- .hoverEvent(HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, Component.text("Click to teleport to " + location, SECONDARY)));
+ .append(Component.text(" " + rankLabel(i) + " ", LIST, TextDecoration.BOLD)) // Camellia - Catppuccin Mocha: Sapphire rank marker
+ .append(Component.text(" " + rankLabel(i) + " ", LIST, TextDecoration.BOLD)) // Shiroha - Catppuccin Mocha: Sapphire rank marker
+ .append(Component.text(location + "\n", INFORMATION))
+
+ .append(Component.text(" "))
@@ -269,7 +269,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
+
+ .clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, Payload.string("/minecraft:execute as @s in " + world.getWorld().getKey().toString() + " run tp " + centerBlockX + ".5 " + yLoc + " " + centerBlockZ + ".5")))
+ .hoverEvent(HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, Component.text("Click to teleport to " + location, SECONDARY)));
+ // Camellia end
+ // Shiroha end
lowestRegionsBuilder.append(line);
}
@@ -318,7 +318,7 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
-
- .append(lowestRegionsBuilder.build())
- .build()
+ // Camellia start - prettier /tps server output
+ // Shiroha start - prettier /tps server output
+ Component.text()
+ .append(sectionHeader("Server Health Report"))
+ .append(divider())
@@ -357,11 +357,11 @@ index aa860cfe9de616f185163fe74e0f4f49bd13a805..3545258acc0f516045594674c6f39f74
+
+ .append(divider())
+ .append(Component.text("\n"))
+ .append(sectionHeader(showAllRegions ? "All " + regions.size() + " regions by utilisation" : "Top " + lowestRegionsCount + " regions by utilisation")) // Camellia - "all" heading
+ .append(sectionHeader(showAllRegions ? "All " + regions.size() + " regions by utilisation" : "Top " + lowestRegionsCount + " regions by utilisation")) // Shiroha - "all" heading
+
+ .append(lowestRegionsBuilder.build())
+ .build()
+ // Camellia end
+ // Shiroha end
);
return true;
@@ -15,7 +15,7 @@ index 491af2413a4e793a121fec368259ff8211ed031e..f9076b71f22b016a117a1eeb9cc4b880
private ServerboundChatCommandPacket(final FriendlyByteBuf input) {
- this(input.readUtf(MAX_CHAT_PACKET_INPUT_SIZE)); // Paper - limit chat command inputs
+ this(moe.monnairealms.camellia.config.modules.fixes.LongCommandSupportConfig.enabled ? input.readUtf() : input.readUtf(MAX_CHAT_PACKET_INPUT_SIZE)); // Paper - limit chat command inputs // Camellia - Add config to support for long command inputs
+ this(moe.monnairealms.camellia.config.modules.fixes.LongCommandSupportConfig.enabled ? input.readUtf() : input.readUtf(MAX_CHAT_PACKET_INPUT_SIZE)); // Paper - limit chat command inputs // Shiroha - Add config to support for long command inputs
}
private void write(final FriendlyByteBuf output) {
@@ -13,7 +13,7 @@ index b01e00de94d8fa45359d3d14a8481287276adb68..cdb1647146f526dc80b15a09d3a936b5
public String getServerModName() {
- return io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); // Paper
+ return moe.monnairealms.camellia.config.modules.misc.ServerModNameConfig.fakeVanilla ? "vanilla" : moe.monnairealms.camellia.config.modules.misc.ServerModNameConfig.serverModName; // Paper // Camellia - Add config for server mod name
+ return moe.monnairealms.camellia.config.modules.misc.ServerModNameConfig.fakeVanilla ? "vanilla" : moe.monnairealms.camellia.config.modules.misc.ServerModNameConfig.serverModName; // Paper // Shiroha - Add config for server mod name
}
public ServerClockManager clockManager() {
@@ -13,7 +13,7 @@ index 5a72fa0d72bfdb927293abe921c57f6ae964a6ec..913161732b0affa70fb114dd4087a610
@Override
public Thread newThread(final Runnable run) {
- final Thread ret = new TickThreadRunner(this.threadGroup, run, "Folia Region Scheduler Thread #" + this.idGenerator.getAndIncrement());
+ final Thread ret = new TickThreadRunner(this.threadGroup, moe.monnairealms.camellia.config.modules.optimizations.CpuAffinityConfig.wrapForTickRegion(run), "Folia Region Scheduler Thread #" + this.idGenerator.getAndIncrement()); // Camellia - Add config for cpu affinity
+ final Thread ret = new TickThreadRunner(this.threadGroup, moe.monnairealms.camellia.config.modules.optimizations.CpuAffinityConfig.wrapForTickRegion(run), "Folia Region Scheduler Thread #" + this.idGenerator.getAndIncrement()); // Shiroha - Add config for cpu affinity
ret.setUncaughtExceptionHandler(TickRegionScheduler.this::uncaughtException);
return ret;
}
@@ -26,8 +26,8 @@ index 9544eaee7e02d00226d957ea0b79cd1a1fb0c4d0..4e138fe36aa0bc519482990b60543b17
private ThreadFactory createThreadFactory() {
- return new ThreadFactoryBuilder().setNameFormat("Netty " + this.type + " IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build(); // Paper
+ var origin = new ThreadFactoryBuilder().setNameFormat("Netty " + this.type + " IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build(); // Paper // Camellia - Add config for cpu affinity
+ return run -> origin.newThread(moe.monnairealms.camellia.config.modules.optimizations.CpuAffinityConfig.wrapForNettyIo(run)); // Camellia - Add config for cpu affinity
+ var origin = new ThreadFactoryBuilder().setNameFormat("Netty " + this.type + " IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build(); // Paper // Shiroha - Add config for cpu affinity
+ return run -> origin.newThread(moe.monnairealms.camellia.config.modules.optimizations.CpuAffinityConfig.wrapForNettyIo(run)); // Shiroha - Add config for cpu affinity
}
protected abstract IoHandlerFactory ioHandlerFactory();
@@ -13,7 +13,7 @@ index 480b6b2405706fd4d7158d0e160adafd84099887..ca8207f7bf6a71ae283c6c9739563e9d
public float fallDamagePerDistance = 0.0F;
public @Nullable CompoundTag blockData;
- public boolean forceTickAfterTeleportToDuplicate;
+ public boolean forceTickAfterTeleportToDuplicate = moe.monnairealms.camellia.config.modules.fixes.UnsafeTeleportationConfig.enabled; // Camellia - Add config for unsafe teleportation
+ public boolean forceTickAfterTeleportToDuplicate = moe.monnairealms.camellia.config.modules.fixes.UnsafeTeleportationConfig.enabled; // Shiroha - Add config for unsafe teleportation
protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS);
public boolean autoExpire = true; // Paper - Expand FallingBlock API
@@ -22,7 +22,7 @@ index 480b6b2405706fd4d7158d0e160adafd84099887..ca8207f7bf6a71ae283c6c9739563e9d
boolean fromOrToEnd = (oldDimension == Level.END || newDimension == Level.END) && oldDimension != newDimension;
Entity newEntity = super.teleport(transition);
- this.forceTickAfterTeleportToDuplicate = newEntity != null && fromOrToEnd && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation; // Paper
+ this.forceTickAfterTeleportToDuplicate = newEntity != null && fromOrToEnd && (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation || moe.monnairealms.camellia.config.modules.fixes.UnsafeTeleportationConfig.enabled); // Paper // Camellia - Add config for unsafe teleportation
+ this.forceTickAfterTeleportToDuplicate = newEntity != null && fromOrToEnd && (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation || moe.monnairealms.camellia.config.modules.fixes.UnsafeTeleportationConfig.enabled); // Paper // Shiroha - Add config for unsafe teleportation
return newEntity;
}
}
@@ -34,12 +34,12 @@ index d42bb2a1721e4ab8c9956e18c3ca418b8d648c59..1bb9e32fd0f112deeec936976da0899d
if (level.paperConfig().misc.disableEndCredits) {player.seenCredits = true; return;} // Paper - Option to disable end credits
player.showEndCredits();
} else {
+ // Camellia start - Add config for unsafe teleportation
+ // Shiroha start - Add config for unsafe teleportation
+ if (moe.monnairealms.camellia.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)) {
+ entity.endPortalLogicAsync(pos);
+ return;
+ }
+ // Camellia end
+ // Shiroha end
entity.setAsInsidePortal(this, pos);
}
}
@@ -13,7 +13,7 @@ index e9ca1a15049b0211d10401cb78e953b93afaf6c7..56c0cac6e6e4c86a1db3c27a2c850d65
for (final RunningTick tick : ticks) {
final long elapsed = now - tick.lastPrint;
- if (elapsed <= TimeUnit.SECONDS.toNanos(5L)) {
+ if (elapsed <= TimeUnit.MILLISECONDS.toNanos(moe.monnairealms.camellia.config.modules.misc.FoliaWatchogConfig.tickRegionTimeOutMs)) { // Camellia - Add config for watchdog timeout
+ if (elapsed <= TimeUnit.MILLISECONDS.toNanos(moe.monnairealms.camellia.config.modules.misc.FoliaWatchogConfig.tickRegionTimeOutMs)) { // Shiroha - Add config for watchdog timeout
continue;
}
tick.lastPrint = now;
@@ -10,9 +10,9 @@ index 52bcb87e96f7b5997559bd532481f548be03e6da..41b84a84a2ae24555a065d0779957b7b
+++ b/net/minecraft/world/level/Level.java
@@ -1591,6 +1591,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
));
// Camellia end
// Shiroha end
} catch (Throwable t) {
+ if (moe.monnairealms.camellia.config.modules.experiment.DisableEntityCatchConfig.enabled) throw t; // Camellia - Add config to disable entity tick catchers
+ if (moe.monnairealms.camellia.config.modules.experiment.DisableEntityCatchConfig.enabled) throw t; // Shiroha - Add config to disable entity tick catchers
// Paper start - Prevent block entity and entity crashes
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", io.papermc.paper.util.MCUtil.getLevelName(entity.level()), entity.getX(), entity.getY(), entity.getZ());
MinecraftServer.LOGGER.error(msg, t);
@@ -12,7 +12,7 @@ index dffa0d4859ecd7e21a9345f946083c56205145a3..8f2e4fa566cefc2089fb6f306a37939f
if (rawData.length == data.length) {
System.arraycopy(data, 0, rawData, 0, data.length);
} else {
+ if (!moe.monnairealms.camellia.config.modules.misc.DisableWarningConfig.disableHeightmapWarning) // Camellia - Add config for heightmap warning
+ if (!moe.monnairealms.camellia.config.modules.misc.DisableWarningConfig.disableHeightmapWarning) // Shiroha - Add config for heightmap warning
LOGGER.warn("Ignoring heightmap data for chunk {}, size does not match; expected: {}, got: {}", chunk.getPos(), rawData.length, data.length);
primeHeightmaps(chunk, EnumSet.of(type));
}
@@ -13,7 +13,7 @@ index 8a720ef5cd10bf04e97fb34c1ca0f0b265e98468..cbe7ebb8f3b3de6cdb0893c24b52c7cf
private final StringTemplate parsed;
- private ParsedTemplate(final String raw, final StringTemplate parsed) {
+ public ParsedTemplate(final String raw, final StringTemplate parsed) { // Camellia - Add config gui support - make public
+ public ParsedTemplate(final String raw, final StringTemplate parsed) { // Shiroha - Add config gui support - make public
this.raw = raw;
this.parsed = parsed;
}
@@ -13,9 +13,9 @@ index bc9f6cc286536b87513de81855ad0b61cf787c84..6b91eab354d8e7c93bf148bfc1f5a611
//CloneCommands.register(this.dispatcher, context); // Folia - region threading - TODO
DamageCommand.register(this.dispatcher, context);
- //DataCommands.register(this.dispatcher); // Folia - region threading - TODO
+ if(moe.monnairealms.camellia.config.modules.experiment.CommandConfig.data) { // Camellia - Add force the data command to be enabled config
+ DataCommands.register(this.dispatcher); // Folia - region threading - TODO // Camellia - Add force the data command to be enabled config
+ } // Camellia - Add force the data command to be enabled config
+ if(moe.monnairealms.camellia.config.modules.experiment.CommandConfig.data) { // Shiroha - Add force the data command to be enabled config
+ DataCommands.register(this.dispatcher); // Folia - region threading - TODO // Shiroha - Add force the data command to be enabled config
+ } // Shiroha - Add force the data command to be enabled config
//DataPackCommand.register(this.dispatcher, context); // Folia - region threading - TODO
//DebugCommand.register(this.dispatcher); // Folia - region threading - TODO
DefaultGameModeCommands.register(this.dispatcher);
@@ -13,7 +13,7 @@ index 31f1583f29eebe5e13b5a7ac5116fdafc3592e5c..bc567e04791128cc0b78a234c496cf99
public boolean performCommand(final ServerLevel level) {
- if (true) return false; // Folia - region threading
+ if (!moe.monnairealms.camellia.config.modules.experiment.CommandConfig.commandBlock) return false; // Folia - region threading // Camellia - Add experimental config for command block command execution
+ if (!moe.monnairealms.camellia.config.modules.experiment.CommandConfig.commandBlock) return false; // Folia - region threading // Shiroha - Add experimental config for command block command execution
if (level.getGameTime() == this.lastExecution) {
return false;
}
@@ -15,7 +15,7 @@ index 8bcc8b6f83ab4d5a472741185511b5d84f4974be..7e78e67c32f5b577518fe735eaba4ce2
- BlockState testPosState = level.getBlockState(testPos);
- if (testPosState.is(Blocks.TRIPWIRE) || testPosState.is(Blocks.TRIPWIRE_HOOK)) {
- if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !testPosState.is(Blocks.TRIPWIRE)) level.setBlock(testPos, wireData.trySetValue(ATTACHED, attached), Block.UPDATE_ALL); // Paper - prevent tripwire from updating
+ // Camellia start - tripwire and tripwireHook dupe
+ // Shiroha start - tripwire and tripwireHook dupe
+ if (moe.monnairealms.camellia.config.modules.function.TripwireBehaviorConfig.enabled) {
+ level.setBlock(testPos, wireData.trySetValue(ATTACHED, attached), 3);
+ level.getBlockState(testPos);
@@ -25,7 +25,7 @@ index 8bcc8b6f83ab4d5a472741185511b5d84f4974be..7e78e67c32f5b577518fe735eaba4ce2
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !testPosState.is(Blocks.TRIPWIRE)) level.setBlock(testPos, wireData.trySetValue(ATTACHED, attached), Block.UPDATE_ALL); // Paper - prevent tripwire from updating
+ }
}
+ // Camellia end - tripwire and tripwireHook dupe
+ // Shiroha end - tripwire and tripwireHook dupe
}
}
}
@@ -38,7 +38,7 @@ index b67f5f7b76037ab77548c37a83e4d0918915223a..4407333785e8e76d08bb8b18510e6db9
BlockPos.MutableBlockPos pos = origin.mutable();
- for (int dz = -2; dz <= 2; dz++) {
+ // Camellia start - tripwire behavior modifier
+ // Shiroha start - tripwire behavior modifier
+ java.util.List<BlockPos> blockList1 = new java.util.ArrayList<>();
+ java.util.List<BlockPos> blockList2 = new java.util.ArrayList<>();
+ boolean flag21 = moe.monnairealms.camellia.config.modules.function.TripwireBehaviorConfig.behaviorMode == moe.monnairealms.camellia.enums.EnumTripwireBehavior.VANILLA21; for (int dz = -2; dz <= 2; dz++) {
@@ -73,7 +73,7 @@ index b67f5f7b76037ab77548c37a83e4d0918915223a..4407333785e8e76d08bb8b18510e6db9
+ if (flag) blockList1.add(blockPos.immutable());
+ else blockList.destroyBlock(blockPos, true, null); // CraftBukkit
}
+ // Camellia end - prevent tripwire dupe in end platform generate
+ // Shiroha end - prevent tripwire dupe in end platform generate
blockList.setBlock(blockPos, block.defaultBlockState(), Block.UPDATE_ALL); // CraftBukkit
}
@@ -83,28 +83,28 @@ index b67f5f7b76037ab77548c37a83e4d0918915223a..4407333785e8e76d08bb8b18510e6db9
- if (dropResources) {
- blockList.placeBlocks(state -> newLevel.destroyBlock(state.getPosition(), true, null));
+ // Camellia start - prevent tripwire dupe in end platform generate
+ // Shiroha start - prevent tripwire dupe in end platform generate
+ if (flag21 || !moe.monnairealms.camellia.config.modules.function.TripwireBehaviorConfig.enabled) {
+ if (dropResources) {
+ blockList.placeBlocks(state -> newLevel.destroyBlock(state.getPosition(), true, null));
+ } else {
+ blockList.placeBlocks();
+ }
+ // Camellia end - prevent tripwire dupe in end platform generate
+ // Shiroha end - prevent tripwire dupe in end platform generate
} else {
+ // Camellia start - prevent tripwire dupe in end platform generate
+ // Shiroha start - prevent tripwire dupe in end platform generate
+ if (dropResources) {
+ blockList.getSnapshotBlocks().forEach((state) -> {
+ newLevel.destroyBlock(state.getPosition(), !blockList1.contains(state.getPosition()), null);
+ });
+ }
+ // Camellia end - prevent tripwire dupe in end platform generate
+ // Shiroha end - prevent tripwire dupe in end platform generate
blockList.placeBlocks();
}
// CraftBukkit end
}
+
+ // Camellia start - tripwire behavior modifier
+ // Shiroha start - tripwire behavior modifier
+ private static boolean checkString(java.util.List<BlockPos> blockList, BlockPos blockPos) {
+ for (BlockPos pos : blockList) {
+ if (pos.getY() != blockPos.getY()) continue;
@@ -112,5 +112,5 @@ index b67f5f7b76037ab77548c37a83e4d0918915223a..4407333785e8e76d08bb8b18510e6db9
+ }
+ return false;
+ }
+ // Camellia end - tripwire behavior modifier
+ // Shiroha end - tripwire behavior modifier
}
@@ -15,9 +15,9 @@ index 4c9ea818be83ed3c4dacc762f4d0e8c0f177cd19..9fe5ee1c5578be6f6c5ad9a58e10669a
this.player.sendSpawnProtectionMessage(pos);
} else if (this.awaitingPositionFromClient == null && (level.mayInteract(this.player, pos) || passthroughSignInteraction)) {
// Paper end - Allow using signs inside spawn protection
+ if (!moe.monnairealms.camellia.config.modules.fixes.ItemMultitaskConfig.enabled) { // Camellia - Add config for item multitask
+ if (!moe.monnairealms.camellia.config.modules.fixes.ItemMultitaskConfig.enabled) { // Shiroha - Add config for item multitask
this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
+ } // Camellia - Add config for item multitask
+ } // Shiroha - Add config for item multitask
InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, level, itemStack, hand, blockHit);
if (interactionResult.consumesAction()) {
CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, blockHit.getBlockPos(), itemStack);
@@ -27,13 +27,13 @@ index 4c9ea818be83ed3c4dacc762f4d0e8c0f177cd19..9fe5ee1c5578be6f6c5ad9a58e10669a
// CraftBukkit end
- if (this.player.getInventory().getSelectedSlot() != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
- this.player.stopUsingItem();
+ // Camellia start - Add item multitask config
+ // Shiroha start - Add item multitask config
+ if (!moe.monnairealms.camellia.config.modules.fixes.ItemMultitaskConfig.enabled) {
+ if (this.player.getInventory().getSelectedSlot() != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
+ this.player.stopUsingItem();
+ }
}
+ // Camellia end
+ // Shiroha end
this.player.getInventory().setSelectedSlot(packet.getSlot());
this.player.resetLastActionTime();
@@ -13,11 +13,11 @@ index aa575f3b76ef70ffb9f0410e7e5cfe7af384bfbd..a00b086962b68d6f86cfb55eee6f61af
private void globalTick(final long tickCount) {
++this.tickCount;
+ // Camellia start - Add a config to enable tick command
+ // Shiroha start - Add a config to enable tick command
+ if (moe.monnairealms.camellia.config.modules.experiment.CommandConfig.tick) {
+ MinecraftServer.getServer().tickRateManager().tick();
+ }
+ // Camellia end - Add a config to enable tick command
+ // Shiroha end - Add a config to enable tick command
// expire invalid click command callbacks
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick
@@ -26,7 +26,7 @@ index aa575f3b76ef70ffb9f0410e7e5cfe7af384bfbd..a00b086962b68d6f86cfb55eee6f61af
private void tickTime(final ServerLevel world, final long tickCount) {
- if (world.tickTime) {
+ if ((!moe.monnairealms.camellia.config.modules.experiment.CommandConfig.tick || world.tickRateManager().runsNormally()) && world.tickTime) { // Camellia - Add a config to enable tick command
+ if ((!moe.monnairealms.camellia.config.modules.experiment.CommandConfig.tick || world.tickRateManager().runsNormally()) && world.tickTime) { // Shiroha - Add a config to enable tick command
world.serverLevelData.setGameTime(world.serverLevelData.getGameTime() + tickCount);
}
}
@@ -38,11 +38,11 @@ index 913161732b0affa70fb114dd4087a6102b611cba..ccd86db7b384d99d290869a155792b49
try {
// next start isn't updated until the end of this tick
this.tickRegion(tickCount, tickStart, scheduledEnd);
+ // Camellia start - Add a config to enable tick command
+ // Shiroha start - Add a config to enable tick command
+ if (moe.monnairealms.camellia.config.modules.experiment.CommandConfig.tick) {
+ MinecraftServer.getServer().tickRateManager().endTickWork();
+ }
+ // Camellia end - Add a config to enable tick command
+ // Shiroha end - Add a config to enable tick command
} catch (final Throwable thr) {
this.scheduler.regionFailed(this, false, thr);
// regionFailed will schedule a shutdown, so we should avoid letting this region tick further
@@ -55,11 +55,11 @@ index 6b91eab354d8e7c93bf148bfc1f5a611f8ffcf86..d971cc9669aca1005c026133e7e7e7f9
TellRawCommand.register(this.dispatcher, context);
//TestCommand.register(this.dispatcher, context); // Folia - region threading
- //TickCommand.register(this.dispatcher); // Folia - region threading - TODO later
+ // Camellia start - Add a config to enable tick command
+ // Shiroha start - Add a config to enable tick command
+ if (moe.monnairealms.camellia.config.modules.experiment.CommandConfig.tick) {
+ TickCommand.register(this.dispatcher); // Folia - region threading - TODO later
+ }
+ // Camellia end - Add a config to enable tick command
+ // Shiroha end - Add a config to enable tick command
TimeCommand.register(this.dispatcher, context);
TitleCommand.register(this.dispatcher, context);
//TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later
@@ -72,7 +72,7 @@ index e8d6a67143f3f0b4813e51bb273498bc404899b9..12ff74e46d39d3bf6f025cc59a27ba89
.requires(Commands.hasPermission(Commands.LEVEL_ADMINS))
.then(Commands.literal("query").executes(c -> tickQuery(c.getSource())))
- .then(
+/* .then( // Camellia - Add config to enable tick command - limit unsupported functions
+/* .then( // Shiroha - Add config to enable tick command - limit unsupported functions
Commands.literal("rate")
.then(
Commands.argument("rate", FloatArgumentType.floatArg(1.0F, 10000.0F))
@@ -80,7 +80,7 @@ index e8d6a67143f3f0b4813e51bb273498bc404899b9..12ff74e46d39d3bf6f025cc59a27ba89
.executes(c -> setTickingRate(c.getSource(), FloatArgumentType.getFloat(c, "rate")))
)
- )
+ )*/ // Camellia - Add config to enable tick command - limit unsupported functions
+ )*/ // Shiroha - Add config to enable tick command - limit unsupported functions
.then(
Commands.literal("step")
.executes(c -> step(c.getSource(), 1))
@@ -89,7 +89,7 @@ index e8d6a67143f3f0b4813e51bb273498bc404899b9..12ff74e46d39d3bf6f025cc59a27ba89
)
)
- .then(
+/* .then( // Camellia - Add config to enable tick command - limit unsupported functions
+/* .then( // Shiroha - Add config to enable tick command - limit unsupported functions
Commands.literal("sprint")
.then(Commands.literal("stop").executes(c -> stopSprinting(c.getSource())))
.then(
@@ -98,7 +98,7 @@ index e8d6a67143f3f0b4813e51bb273498bc404899b9..12ff74e46d39d3bf6f025cc59a27ba89
.executes(c -> sprint(c.getSource(), IntegerArgumentType.getInteger(c, "time")))
)
- )
+ )*/ // Camellia - Add config to enable tick command - limit unsupported functions
+ )*/ // Shiroha - Add config to enable tick command - limit unsupported functions
.then(Commands.literal("unfreeze").executes(c -> setFreeze(c.getSource(), false)))
.then(Commands.literal("freeze").executes(c -> setFreeze(c.getSource(), true)))
);
@@ -13,7 +13,7 @@ index 7e612e03087d63f9b500f7e9f3442b1931bae7ee..9d46c1bc0629faca4ca9e0a2f830912b
public static final TicketType PLAYER_SIMULATION = register("player_simulation", NO_TIMEOUT, FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE);
public static final TicketType FORCED = register("forced", NO_TIMEOUT, FLAG_PERSIST | FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE);
- public static final TicketType PORTAL = register("portal", 300L, FLAG_PERSIST | FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE);
+ public static final TicketType PORTAL = register("portal", 300L, moe.monnairealms.camellia.config.modules.misc.SavePortalTicketsConfig.doSave ? FLAG_PERSIST | FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE : FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE); // Camellia - Add config for whether to save portal tickets
+ public static final TicketType PORTAL = register("portal", 300L, moe.monnairealms.camellia.config.modules.misc.SavePortalTicketsConfig.doSave ? FLAG_PERSIST | FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE : FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE); // Shiroha - Add config for whether to save portal tickets
public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE);
public static final TicketType UNKNOWN = register("unknown", 1L, FLAG_CAN_EXPIRE_IF_UNLOADED | FLAG_LOADING);
public static final TicketType PLUGIN = register("plugin", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // CraftBukkit
@@ -12,10 +12,10 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..fe17157c4c6fc9ec745c5c11f6837e71
for (final ChunkHolder chunkHolder : from.chunkHoldersToBroadcast) {
into.chunkHoldersToBroadcast.add(chunkHolder);
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ into.portalRateThrottler.mergeWith(from.portalRateThrottler);
+ from.portalRateThrottler.destroy();
+ // Camellia end
+ // Shiroha end
}
@Override
@@ -23,12 +23,12 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..fe17157c4c6fc9ec745c5c11f6837e71
into.chunkHoldersToBroadcast.add(chunkHolder);
}
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ for (var worldData : dataSet) {
+ from.portalRateThrottler.splitInto(worldData.portalRateThrottler);
+ }
+ from.portalRateThrottler.destroy();
+ // Camellia end
+ // Shiroha end
}
};
@@ -36,7 +36,7 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..fe17157c4c6fc9ec745c5c11f6837e71
return this.isHandlingTick;
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ public final moe.monnairealms.camellia.utils.RateThrottler portalRateThrottler = new moe.monnairealms.camellia.utils.RateThrottler();
+ public final net.objecthunter.exp4j.Expression portalRateCapExpression = moe.monnairealms.camellia.config.modules.function.PortalRateLimiterConfig.getExpressionIfConfigured();
+
@@ -64,7 +64,7 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..fe17157c4c6fc9ec745c5c11f6837e71
+
+ return this.portalRateThrottler.isOutOfRate(this.computePortalRateCap());
+ }
+ // Camellia end
+ // Shiroha end
// entities
// this is copy on write to allow packet processing to iterate safely
private final CopyOnWriteArrayList<ServerPlayer> localPlayers = new CopyOnWriteArrayList<>();
@@ -76,9 +76,9 @@ index cdb1647146f526dc80b15a09d3a936b5dbc54ba3..4ce5bdd16b04f76c2e98a5465343a82e
//net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = level.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers // Folia - region threading
profiler.push(() -> level + " " + level.dimension().identifier());
profiler.push("tick");
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ regionizedWorldData.portalRateThrottler.begin();
+ // Camellia end
+ // Shiroha end
try {
foliaProfiler.startTimer(level.tickTimerId); try { // Folia - profiler
@@ -86,9 +86,9 @@ index cdb1647146f526dc80b15a09d3a936b5dbc54ba3..4ce5bdd16b04f76c2e98a5465343a82e
profiler.pop();
profiler.pop();
regionizedWorldData.explosionDensityCache.clear(); // Paper - Optimize explosions // Folia - region threading
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ regionizedWorldData.portalRateThrottler.done();
+ // Camellia end
+ // Shiroha end
}
//this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked // Folia - region threading
@@ -100,15 +100,15 @@ index 0097c55adf5578f425b476b3498db1c701189e4b..1a0e5fbc823c328d16f48f2df4507bf2
// removed from region while ticking
return;
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ var worldData = entity.level().getCurrentWorldData();
+ if (entity.portalProcess != null && worldData.isPortalTeleportationOutOfRate()) {
+ return;
+ }
+ // Camellia end
+ // Shiroha end
if (entity.handlePortal()) {
// portalled
+ worldData.portalRateThrottler.increase(); // Camellia - Add portal rate limiter
+ worldData.portalRateThrottler.increase(); // Shiroha - Add portal rate limiter
return;
}
}
@@ -116,15 +116,15 @@ index 0097c55adf5578f425b476b3498db1c701189e4b..1a0e5fbc823c328d16f48f2df4507bf2
// removed from region while ticking
return;
}
+ // Camellia start - Add portal rate limiter
+ // Shiroha start - Add portal rate limiter
+ var worldData = entity.level().getCurrentWorldData();
+ if (entity.portalProcess != null && worldData.isPortalTeleportationOutOfRate()) {
+ return;
+ }
+ // Camellia end
+ // Shiroha end
if (entity.handlePortal()) {
// portalled
+ worldData.portalRateThrottler.increase(); // Camellia - Add portal rate limiter
+ worldData.portalRateThrottler.increase(); // Shiroha - Add portal rate limiter
return;
}
// Folia end - region threading
@@ -113,9 +113,9 @@ index f22b5fdec6da8bcff9aef3d9fed5dbe61d39250a..336a1ae13810207696a699a936d4031e
@Override
public void tick() {
+ // Camellia start - Add status bars
+ // Shiroha start - Add status bars
+ this.statusBarList.tick();
+ // Camellia end - Add status bars
+ // Shiroha end - Add status bars
// CraftBukkit start
if (this.joining) {
this.joining = false;
@@ -253,7 +253,7 @@ index 2eb5fc819e2e17c69de87f8aa1a99e02bc5a62d5..ab0f42c6ed9ba4f920eefba4d1449ded
private ItemStack lastItemInMainHand = ItemStack.EMPTY;
private final ItemCooldowns cooldowns = this.createItemCooldowns();
private Optional<GlobalPos> lastDeathLocation = Optional.empty();
+ public moe.monnairealms.camellia.functions.bars.TickableStatusBarList statusBarList = new moe.monnairealms.camellia.functions.bars.TickableStatusBarList(this); // Camellia - Add status bars
+ public moe.monnairealms.camellia.functions.bars.TickableStatusBarList statusBarList = new moe.monnairealms.camellia.functions.bars.TickableStatusBarList(this); // Shiroha - Add status bars
public @Nullable FishingHook fishing;
public float hurtDir;
public boolean affectsSpawning = true; // Paper - Affects Spawning API
@@ -261,7 +261,7 @@ index 2eb5fc819e2e17c69de87f8aa1a99e02bc5a62d5..ab0f42c6ed9ba4f920eefba4d1449ded
this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(this.abilities.getWalkingSpeed());
this.enderChestInventory.fromSlots(input.listOrEmpty("EnderItems", ItemStackWithSlot.CODEC));
this.setLastDeathLocation(input.read("LastDeathLocation", GlobalPos.CODEC));
+ this.statusBarList.load(input); // Camellia - Add status bars
+ this.statusBarList.load(input); // Shiroha - Add status bars
}
@Override
@@ -269,7 +269,7 @@ index 2eb5fc819e2e17c69de87f8aa1a99e02bc5a62d5..ab0f42c6ed9ba4f920eefba4d1449ded
output.store("abilities", Abilities.Packed.CODEC, this.abilities.pack());
this.enderChestInventory.storeAsSlots(output.list("EnderItems", ItemStackWithSlot.CODEC));
this.lastDeathLocation.ifPresent(pos -> output.store("LastDeathLocation", GlobalPos.CODEC, pos));
+ this.statusBarList.save(output); // Camellia - Add status bars
+ this.statusBarList.save(output); // Shiroha - Add status bars
}
@Override
@@ -16,10 +16,10 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
import java.util.function.Predicate;
+// Camellia start - imports for lithium sleeping block entity
+// Shiroha start - imports for lithium sleeping block entity
+import org.leavesmc.leaves.lithium.common.tracking.entity.ChunkSectionInventoryEntityTracker;
+import org.leavesmc.leaves.lithium.common.tracking.entity.ChunkSectionItemEntityMovementTracker;
+// Camellia end
+// Shiroha end
public final class RegionizedWorldData {
@@ -27,7 +27,7 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
public static final RegionizedData.RegioniserCallback<RegionizedWorldData> REGION_CALLBACK = new RegionizedData.RegioniserCallback<>() {
@Override
public void merge(final RegionizedWorldData from, final RegionizedWorldData into, final long fromTickOffset) {
+ // Camellia start - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ // lithium listeners
+ final long fromRedstoneTimeOffsetForLithiumTracker = into.redstoneTime - from.redstoneTime;
+ for (var entry : from.containerEntityMovementTrackerMap.entrySet()) {
@@ -52,7 +52,7 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
+ tracker.updateTicks(fromTickOffset, fromRedstoneTimeOffsetForLithiumTracker);
+ into.itemEntityMovementTrackerMap.put(key, tracker);
+ }
+ // Camellia end
+ // Shiroha end
// connections
for (final Connection conn : from.connections) {
into.connections.add(conn);
@@ -61,25 +61,25 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
// tile entity ticking
- for (final TickingBlockEntity tileEntityWrapped : from.pendingBlockEntityTickers) {
+ for (TickingBlockEntity tileEntityWrapped : from.pendingBlockEntityTickers) { // Camellia - Region threading for lithium sleeping block entity
+ for (TickingBlockEntity tileEntityWrapped : from.pendingBlockEntityTickers) { // Shiroha - Region threading for lithium sleeping block entity
into.pendingBlockEntityTickers.add(tileEntityWrapped);
- final BlockEntity tileEntity = tileEntityWrapped.getTileEntity();
+ BlockEntity tileEntity = tileEntityWrapped.getTileEntity(); // Camellia - Region threading for lithium sleeping block entity
+ // Camellia start - Region threading for lithium sleeping block entity
+ BlockEntity tileEntity = tileEntityWrapped.getTileEntity(); // Shiroha - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ tileEntityWrapped.updateTicksForLithium(fromRedstoneTimeOffset);
+ // Camellia end - Region threading for lithium sleeping block entity
+ // Shiroha end - Region threading for lithium sleeping block entity
if (tileEntity != null) {
tileEntity.updateTicks(fromTickOffset, fromRedstoneTimeOffset);
}
}
- for (final TickingBlockEntity tileEntityWrapped : from.blockEntityTickers) {
+ for (TickingBlockEntity tileEntityWrapped : from.blockEntityTickers) { // Camellia - Region threading for lithium sleeping block entity
+ for (TickingBlockEntity tileEntityWrapped : from.blockEntityTickers) { // Shiroha - Region threading for lithium sleeping block entity
into.blockEntityTickers.add(tileEntityWrapped);
- final BlockEntity tileEntity = tileEntityWrapped.getTileEntity();
+ BlockEntity tileEntity = tileEntityWrapped.getTileEntity(); // Camellia - Region threading for lithium sleeping block entity
+ // Camellia start - Region threading for lithium sleeping block entity
+ BlockEntity tileEntity = tileEntityWrapped.getTileEntity(); // Shiroha - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ tileEntityWrapped.updateTicksForLithium(fromRedstoneTimeOffset);
+ // Camellia end - Region threading for lithium sleeping block entity
+ // Shiroha end - Region threading for lithium sleeping block entity
if (tileEntity != null) {
tileEntity.updateTicks(fromTickOffset, fromRedstoneTimeOffset);
}
@@ -87,7 +87,7 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
public void split(final RegionizedWorldData from, final int chunkToRegionShift,
final Long2ReferenceOpenHashMap<RegionizedWorldData> regionToData,
final ReferenceOpenHashSet<RegionizedWorldData> dataSet) {
+ // Camellia start - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ // lithium entity movement listeners
+ for (var entry : from.containerEntityMovementTrackerMap.entrySet()) {
+ final long key = entry.getKey();
@@ -117,7 +117,7 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
+
+ regionToData.get(CoordinateUtils.getChunkKey(pos.x() >> chunkToRegionShift, pos.z() >> chunkToRegionShift)).itemEntityMovementTrackerMap.put(key, tracker);
+ }
+ // Camellia end
+ // Shiroha end
// connections
for (final Connection conn : from.connections) {
final ServerPlayer player = conn.getPlayer();
@@ -127,9 +127,9 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
// tile entity ticking
- for (final TickingBlockEntity tileEntity : from.pendingBlockEntityTickers) {
- final BlockPos pos = tileEntity.getPos();
+ for (final TickingBlockEntity tileEntity : from.pendingBlockEntityTickers) { // Camellia - Region threading for lithium sleeping block entity
+ BlockPos pos = tileEntity.getPos(); // Camellia - Region threading for lithium sleeping block entity
+ if (pos == null) pos = tileEntity.getTileEntity().getBlockPos(); // Camellia - Region threading for lithium sleeping block entity
+ for (final TickingBlockEntity tileEntity : from.pendingBlockEntityTickers) { // Shiroha - Region threading for lithium sleeping block entity
+ BlockPos pos = tileEntity.getPos(); // Shiroha - Region threading for lithium sleeping block entity
+ if (pos == null) pos = tileEntity.getTileEntity().getBlockPos(); // Shiroha - Region threading for lithium sleeping block entity
final int chunkX = pos.getX() >> 4;
final int chunkZ = pos.getZ() >> 4;
@@ -139,9 +139,9 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
}
- for (final TickingBlockEntity tileEntity : from.blockEntityTickers) {
- final BlockPos pos = tileEntity.getPos();
+ for (final TickingBlockEntity tileEntity : from.blockEntityTickers) { // Camellia - Region threading for lithium sleeping block entity
+ BlockPos pos = tileEntity.getPos(); // Camellia - Region threading for lithium sleeping block entity
+ if (pos == null) pos = tileEntity.getTileEntity().getBlockPos(); // Camellia - Region threading for lithium sleeping block entity
+ for (final TickingBlockEntity tileEntity : from.blockEntityTickers) { // Shiroha - Region threading for lithium sleeping block entity
+ BlockPos pos = tileEntity.getPos(); // Shiroha - Region threading for lithium sleeping block entity
+ if (pos == null) pos = tileEntity.getTileEntity().getBlockPos(); // Shiroha - Region threading for lithium sleeping block entity
final int chunkX = pos.getX() >> 4;
final int chunkZ = pos.getZ() >> 4;
@@ -149,11 +149,11 @@ index fe17157c4c6fc9ec745c5c11f6837e715d7949ab..be3bdce1b42a32f57d9ec71d8f115ea1
public final io.papermc.paper.redstone.RedstoneWireTurbo turbo;
// Environment attribute system
public Reference2ObjectOpenHashMap<EnvironmentAttribute<?>, EnvironmentAttributeSystem.ValueSampler<?>> attributeSamplers;
+ // Camellia start - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ // Lithium
+ public final Map<Long, ChunkSectionInventoryEntityTracker> containerEntityMovementTrackerMap = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>();
+ public final Map<Long, ChunkSectionItemEntityMovementTracker> itemEntityMovementTrackerMap = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>();
+ // Camellia end
+ // Shiroha end
public final TickRegions.TickRegionData regionData;
@@ -256,24 +256,24 @@ index 18e0572fe28461e57edb13e6ed6f5a0b6b3604c9..83914a091cc8fd6ef726f2732238b164
}
protected Entity transformForAsyncTeleport(ServerLevel destination, Vec3 pos, Float yaw, Float pitch, Vec3 velocity) {
+ final boolean toSameWorld = this.level != destination; // Camellia - Region threading for lithium sleeping block entity
+ final boolean toSameWorld = this.level != destination; // Shiroha - Region threading for lithium sleeping block entity
this.removeAfterChangingDimensions(); // remove before so that any CBEntity#getHandle call affects this entity before copying
Entity copy = this.getType().create(destination, EntitySpawnReason.DIMENSION_TRAVEL);
copy.restoreFrom(this);
copy.transform(pos, yaw, pitch, velocity);
+ if (toSameWorld) copy.notifyLithiumTrackerIfNeeded(); // Camellia - Region threading for lithium sleeping block entity
if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Camellia - Fix dragon part desync
+ if (toSameWorld) copy.notifyLithiumTrackerIfNeeded(); // Shiroha - Region threading for lithium sleeping block entity
if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Shiroha - Fix dragon part desync
// vanilla code used to call remove _after_ copying, and some stuff is required to be after copy - so add hook here
// for example, clearing of inventory after switching dimensions
@@ -5953,8 +5955,29 @@ public abstract class Entity
this.setBoundingBox(this.makeBoundingBox());
}
// Paper end - Block invalid positions and bounding box
+ this.notifyLithiumTrackerIfNeeded(); // Camellia - Leaves lithium sleeping block entity
+ this.notifyLithiumTrackerIfNeeded(); // Shiroha - Leaves lithium sleeping block entity
}
+ // Camellia start - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ private void notifyLithiumTrackerIfNeeded() {
+ // Leaves start - Lithium Sleeping Block Entity
+ if (!moe.monnairealms.camellia.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled) return;
@@ -282,16 +282,16 @@ index 18e0572fe28461e57edb13e6ed6f5a0b6b3604c9..83914a091cc8fd6ef726f2732238b164
+ if (this instanceof ItemEntity) {
+ long sectionKey = ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkSectionKey(this);
+ org.leavesmc.leaves.lithium.common.tracking.entity.ChunkSectionItemEntityMovementTracker tracker = currentWorldData.itemEntityMovementTrackerMap.get(sectionKey);
+ if (tracker != null) tracker.notifyAllListeners(currentWorldData.getRedstoneGameTime()); // Camellia - Region threading for lithium sleeping block entity
+ if (tracker != null) tracker.notifyAllListeners(currentWorldData.getRedstoneGameTime()); // Shiroha - Region threading for lithium sleeping block entity
+ }
+ else if (this instanceof net.minecraft.world.entity.vehicle.ContainerEntity) {
+ long sectionKey = ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkSectionKey(this);
+ org.leavesmc.leaves.lithium.common.tracking.entity.ChunkSectionInventoryEntityTracker tracker = currentWorldData.containerEntityMovementTrackerMap.get(sectionKey);
+ if (tracker != null) tracker.notifyAllListeners(currentWorldData.getRedstoneGameTime()); // Camellia - Region threading for lithium sleeping block entity
+ if (tracker != null) tracker.notifyAllListeners(currentWorldData.getRedstoneGameTime()); // Shiroha - Region threading for lithium sleeping block entity
+ }
+ // Leaves end - Lithium Sleeping Block Entity
+ }
+ // Camellia end
+ // Shiroha end
+
public void checkDespawn() {
}
@@ -1613,10 +1613,10 @@ index 4c9d0bcd8820b250b51c06fff4531021ab57d408..fa34778b1ce7a34385c192182e521b00
public void updateTicks(final long fromTickOffset, final long fromRedstoneTimeOffset) {
super.updateTicks(fromTickOffset, fromRedstoneTimeOffset);
- if (this.tickedGameTime != Long.MIN_VALUE) {
+ if (this.tickedGameTime != Long.MIN_VALUE && this.tickedGameTime != Long.MAX_VALUE) { // Camellia - Region threading for lithium sleeping block entity
+ if (this.tickedGameTime != Long.MIN_VALUE && this.tickedGameTime != Long.MAX_VALUE) { // Shiroha - Region threading for lithium sleeping block entity
this.tickedGameTime += fromRedstoneTimeOffset;
}
+ // Camellia start - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ if (this.insertInventoryEntityFailedSearchTime != Long.MIN_VALUE)
+ this.insertInventoryEntityFailedSearchTime += fromRedstoneTimeOffset;
+
@@ -1625,7 +1625,7 @@ index 4c9d0bcd8820b250b51c06fff4531021ab57d408..fa34778b1ce7a34385c192182e521b00
+
+ if (this.collectItemEntityAttemptTime != Long.MIN_VALUE)
+ this.collectItemEntityAttemptTime += fromRedstoneTimeOffset;
+ // Camellia end
+ // Shiroha end
}
// Folia end - region threading
@@ -2607,9 +2607,9 @@ index c8facee29ee08e0975528083f89b64f0b593957f..2499535f0aa699decad88917ab46fccc
BlockEntity getTileEntity(); // Folia - region threading
+
+ // Camellia start - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ default void updateTicksForLithium(long redstoneGameTimeOffset) {}
+ // Camellia end
+ // Shiroha end
}
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index c78d77089e34c4bb559f173b449bfb7d91b05d5c..f4cce42ddd319cfd11cc43d68044f51b4514af38 100644
@@ -2653,7 +2653,7 @@ index 0e84b695a677e71f443a29c78fc5025eec7ae7f4..3cb6c24a21538569d73b95803dde7e4a
LevelChunk.RebindableTickingBlockEntityWrapper ticker = this.tickersInLevel.remove(pos);
if (ticker != null) {
ticker.rebind(NULL_TICKER);
+ ticker.createdBy = null; // Camellia - Region threading for sleeping block entity
+ ticker.createdBy = null; // Shiroha - Region threading for sleeping block entity
}
}
@@ -2661,7 +2661,7 @@ index 0e84b695a677e71f443a29c78fc5025eec7ae7f4..3cb6c24a21538569d73b95803dde7e4a
this.blockEntities.values().forEach(BlockEntity::setRemoved);
this.blockEntities.clear();
this.tickersInLevel.values().forEach(ticker -> ticker.rebind(NULL_TICKER));
+ this.tickersInLevel.values().forEach(ticker -> ticker.createdBy = null); // Camellia - Region threading for sleeping block entity
+ this.tickersInLevel.values().forEach(ticker -> ticker.createdBy = null); // Shiroha - Region threading for sleeping block entity
this.tickersInLevel.clear();
}
@@ -2670,13 +2670,13 @@ index 0e84b695a677e71f443a29c78fc5025eec7ae7f4..3cb6c24a21538569d73b95803dde7e4a
TickingBlockEntity actualTicker = this.createTicker(blockEntity, ticker);
if (existingTicker != null) {
+ if (moe.monnairealms.camellia.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled && blockEntity instanceof org.leavesmc.leaves.lithium.common.block.entity.SleepingBlockEntity sleepingBlockEntity) sleepingBlockEntity.lithium$setTickWrapper(existingTicker); // Leaves - Lithium Sleeping Block Entity
+ if (moe.monnairealms.camellia.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled) existingTicker.createdBy = blockEntity; // Camellia - Region threading for lithium sleeping block entity
+ if (moe.monnairealms.camellia.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled) existingTicker.createdBy = blockEntity; // Shiroha - Region threading for lithium sleeping block entity
existingTicker.rebind(actualTicker);
return (LevelChunk.RebindableTickingBlockEntityWrapper)existingTicker;
} else if (this.isInLevel()) {
LevelChunk.RebindableTickingBlockEntityWrapper result = new LevelChunk.RebindableTickingBlockEntityWrapper(actualTicker);
+ if (moe.monnairealms.camellia.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled && blockEntity instanceof org.leavesmc.leaves.lithium.common.block.entity.SleepingBlockEntity sleepingBlockEntity) sleepingBlockEntity.lithium$setTickWrapper(result); // Leaves - Lithium Sleeping Block Entity
+ if (moe.monnairealms.camellia.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled) result.createdBy = blockEntity; // Camellia - Region threading for lithium sleeping block entity
+ if (moe.monnairealms.camellia.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled) result.createdBy = blockEntity; // Shiroha - Region threading for lithium sleeping block entity
this.level.addBlockEntityTicker(result);
return result;
} else {
@@ -2688,7 +2688,7 @@ index 0e84b695a677e71f443a29c78fc5025eec7ae7f4..3cb6c24a21538569d73b95803dde7e4a
- private TickingBlockEntity ticker;
+ public static class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { // Leaves - default -> public
+ public TickingBlockEntity ticker; // Leaves - private -> public
+ @org.jetbrains.annotations.Nullable private BlockEntity createdBy; // Camellia - Region threading for lithium sleeping block entity
+ @org.jetbrains.annotations.Nullable private BlockEntity createdBy; // Shiroha - Region threading for lithium sleeping block entity
private RebindableTickingBlockEntityWrapper(final TickingBlockEntity ticker) {
this.ticker = ticker;
@@ -2702,7 +2702,7 @@ index 0e84b695a677e71f443a29c78fc5025eec7ae7f4..3cb6c24a21538569d73b95803dde7e4a
// Folia start - region threading
@Override
public BlockEntity getTileEntity() {
+ // Camellia start - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ if (true) {
+ if (this.ticker != null) {
+ var ret = this.ticker.getTileEntity();
@@ -2716,7 +2716,7 @@ index 0e84b695a677e71f443a29c78fc5025eec7ae7f4..3cb6c24a21538569d73b95803dde7e4a
+
+ return null;
+ }
+ // Camellia end
+ // Shiroha end
return this.ticker == null ? null : this.ticker.getTileEntity();
}
// Folia end - region threading
@@ -2725,7 +2725,7 @@ index 0e84b695a677e71f443a29c78fc5025eec7ae7f4..3cb6c24a21538569d73b95803dde7e4a
return this.ticker + " <wrapped>";
}
+
+ // Camellia start - Region threading for lithium sleeping block entity
+ // Shiroha start - Region threading for lithium sleeping block entity
+ @Override
+ public void updateTicksForLithium(long redstoneGameTimeOffset) {
+ if (this.ticker != null) {
@@ -2733,7 +2733,7 @@ index 0e84b695a677e71f443a29c78fc5025eec7ae7f4..3cb6c24a21538569d73b95803dde7e4a
+ }
+ }
+
+ // Camellia end
+ // Shiroha end
}
@FunctionalInterface
@@ -15,14 +15,14 @@ index 3c59325cb82a66a74d6605b51db83ff63e59e089..cab6061af551352a27e623af2ced3f49
return;
}
// Paper end - Allow nerfed mobs to jump and float
+ int idBasedTickCount = this.tickCount + this.getId(); // Camellia - Petal - Move up
+ int idBasedTickCount = this.tickCount + this.getId(); // Shiroha - Petal - Move up
ProfilerFiller profiler = Profiler.get();
profiler.push("sensing");
- this.sensing.tick();
+ if (idBasedTickCount % moe.monnairealms.camellia.config.modules.optimizations.PetalReduceSensorWorkConfig.delayTicks == 0 || !moe.monnairealms.camellia.config.modules.optimizations.PetalReduceSensorWorkConfig.enabled) this.sensing.tick(); // Camellia - Petal - Reduce sensor work
+ if (idBasedTickCount % moe.monnairealms.camellia.config.modules.optimizations.PetalReduceSensorWorkConfig.delayTicks == 0 || !moe.monnairealms.camellia.config.modules.optimizations.PetalReduceSensorWorkConfig.enabled) this.sensing.tick(); // Shiroha - Petal - Reduce sensor work
profiler.pop();
- int idBasedTickCount = this.tickCount + this.getId();
+ //int idBasedTickCount = this.tickCount + this.getId(); // Camellia - Petal - Move up
+ //int idBasedTickCount = this.tickCount + this.getId(); // Shiroha - Petal - Move up
if (idBasedTickCount % 2 != 0 && this.tickCount > 1) {
profiler.push("targetSelector");
this.targetSelector.tickRunningGoals(false);
@@ -16,10 +16,10 @@ index be3bdce1b42a32f57d9ec71d8f115ea1ceac9d52..fc5161a77a4a846888c564123265a669
private RegionizedServer.WorldLevelData tickData;
+ // Camellia start - Pufferfish - Reduce projectile chunk loading
+ // Shiroha start - Pufferfish - Reduce projectile chunk loading
+ public long pufferfish$loadedThisTick = 0L;
+ public long pufferfish$loadedTick = 0L;
+ // Camellia end
+ // Shiroha end
// connections
public final List<Connection> connections = new ArrayList<>();
@@ -13,8 +13,8 @@ index 7b74440fbbe79c018ad59d24b99da0c6d4a9d007..20536f4ed6d19ec2cc6a54aa9c5c980d
private RandomState(final NoiseGeneratorSettings settings, final HolderGetter<NormalNoise.NoiseParameters> noises, final long seed) {
- this.random = settings.getRandomSource().newInstance(seed).forkPositional();
+ // this.random = settings.getRandomSource().newInstance(seed).forkPositional(); // Camellia - Add secure seed V2 with Blake3
+ // Camellia start - Add secure seed V2 with Blake3
+ // this.random = settings.getRandomSource().newInstance(seed).forkPositional(); // Shiroha - Add secure seed V2 with Blake3
+ // Shiroha start - Add secure seed V2 with Blake3
+ final long[] secureWorldSeed = (moe.monnairealms.camellia.config.modules.function.SecureSeedConfig.enabled && moe.monnairealms.camellia.config.modules.function.SecureSeedConfig.version == 2)
+ ? su.plo.matter.HashingV2.expandLevelSeedTo1024Bits(seed)
+ : null;
@@ -28,15 +28,15 @@ index 7b74440fbbe79c018ad59d24b99da0c6d4a9d007..20536f4ed6d19ec2cc6a54aa9c5c980d
+ long oreSeed = (moe.monnairealms.camellia.config.modules.function.SecureSeedConfig.enabled && moe.monnairealms.camellia.config.modules.function.SecureSeedConfig.version == 2)
+ ? su.plo.matter.HashingV2.getTerrainSeed(secureWorldSeed, su.plo.matter.HashingV2.TerrainType.ORE)
+ : seed;
+ // Camellia end
+ this.random = settings.getRandomSource().newInstance(terrainSeed).forkPositional(); // Camellia - Add secure seed V2 with Blake3
+ // Shiroha end
+ this.random = settings.getRandomSource().newInstance(terrainSeed).forkPositional(); // Shiroha - Add secure seed V2 with Blake3
this.noises = noises;
- this.aquiferRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("aquifer")).forkPositional();
- this.oreRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("ore")).forkPositional();
+ //this.aquiferRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("aquifer")).forkPositional(); // Camellia - Add secure seed V2 with Blake3
+ //this.oreRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("ore")).forkPositional(); // Camellia - Add secure seed V2 with Blake3
+ this.aquiferRandom = settings.getRandomSource().newInstance(aquiferSeed).forkPositional(); // Camellia - Add secure seed V2 with Blake3
+ this.oreRandom = settings.getRandomSource().newInstance(oreSeed).forkPositional(); // Camellia - Add secure seed V2 with Blake3
+ //this.aquiferRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("aquifer")).forkPositional(); // Shiroha - Add secure seed V2 with Blake3
+ //this.oreRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("ore")).forkPositional(); // Shiroha - Add secure seed V2 with Blake3
+ this.aquiferRandom = settings.getRandomSource().newInstance(aquiferSeed).forkPositional(); // Shiroha - Add secure seed V2 with Blake3
+ this.oreRandom = settings.getRandomSource().newInstance(oreSeed).forkPositional(); // Shiroha - Add secure seed V2 with Blake3
this.noiseIntances = new ConcurrentHashMap<>();
this.positionalRandoms = new ConcurrentHashMap<>();
this.surfaceSystem = new SurfaceSystem(this, settings.defaultBlock(), settings.seaLevel(), this.random);
@@ -44,12 +44,12 @@ index 7b74440fbbe79c018ad59d24b99da0c6d4a9d007..20536f4ed6d19ec2cc6a54aa9c5c980d
private final Map<DensityFunction, DensityFunction> wrapped = new HashMap<>();
private RandomSource newLegacyInstance(final long seedOffset) {
+ // Camellia start - Add secure seed V2 with Blake3
+ // Shiroha start - Add secure seed V2 with Blake3
+ if (moe.monnairealms.camellia.config.modules.function.SecureSeedConfig.enabled && moe.monnairealms.camellia.config.modules.function.SecureSeedConfig.version == 2) {
+ long climateSeed = su.plo.matter.HashingV2.getTerrainSeed(secureWorldSeed, su.plo.matter.HashingV2.TerrainType.CLIMATE);
+ return new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.UNDEFINED, climateSeed + seed);
+ }
+ // Camellia end
+ // Shiroha end
return new LegacyRandomSource(seed + seedOffset);
}
@@ -58,12 +58,12 @@ index 7b74440fbbe79c018ad59d24b99da0c6d4a9d007..20536f4ed6d19ec2cc6a54aa9c5c980d
return noise.withNewRandom(terrainRandom);
} else {
- return function instanceof DensityFunctions.EndIslandDensityFunction ? new DensityFunctions.EndIslandDensityFunction(seed) : function;
+ return function instanceof DensityFunctions.EndIslandDensityFunction //? new DensityFunctions.EndIslandDensityFunction(seed)// Camellia - Add secure seed V2 with Blake3
+ // Camellia start - Add secure seed V2 with Blake3
+ return function instanceof DensityFunctions.EndIslandDensityFunction //? new DensityFunctions.EndIslandDensityFunction(seed)// Shiroha - Add secure seed V2 with Blake3
+ // Shiroha start - Add secure seed V2 with Blake3
+ ? new DensityFunctions.EndIslandDensityFunction((moe.monnairealms.camellia.config.modules.function.SecureSeedConfig.enabled && moe.monnairealms.camellia.config.modules.function.SecureSeedConfig.version == 2)
+ ? su.plo.matter.HashingV2.getTerrainSeed(secureWorldSeed, su.plo.matter.HashingV2.TerrainType.SURFACE)
+ : seed)
+ // Camellia end
+ // Shiroha end
+ : function;
}
}
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
Date: Sun, 28 Jun 2026 20:57:48 +0800
Subject: [PATCH] Leaves: Disable packet limit & Camellia: Option to full
Subject: [PATCH] Leaves: Disable packet limit & Shiroha: Option to full
disable packet limiter
@@ -15,8 +15,8 @@ index d0dff5850717bd083b7a29104a61754ce1b2f822..d0809790e3b3526622af4f7a7eca6c52
}
- if (this.allPacketCounts != null ||
- io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass())) {
+ if (!moe.monnairealms.camellia.config.modules.misc.PaperPacketLimiterConfig.forceDisable && (this.allPacketCounts != null || // Camellia - Add config to force disable the packet limiter of Paper
+ io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass()))) { // Camellia - Add config to force disable the packet limiter of Paper
+ if (!moe.monnairealms.camellia.config.modules.misc.PaperPacketLimiterConfig.forceDisable && (this.allPacketCounts != null || // Shiroha - Add config to force disable the packet limiter of Paper
+ io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass()))) { // Shiroha - Add config to force disable the packet limiter of Paper
long time = System.nanoTime();
synchronized (PACKET_LIMIT_LOCK) {
if (this.allPacketCounts != null) {
@@ -65,7 +65,7 @@ index fca5017a13148a928ae320ee99cddc45f617ffcd..c22f17a517254541b1ca627ec149cbe9
// Paper start - optimise random ticking
- private final io.papermc.paper.threadedregions.util.SimpleThreadLocalRandomSource simpleRandom = io.papermc.paper.threadedregions.util.SimpleThreadLocalRandomSource.INSTANCE; // Folia - region threading
+ public final io.papermc.paper.threadedregions.util.SimpleThreadLocalRandomSource simpleRandom = io.papermc.paper.threadedregions.util.SimpleThreadLocalRandomSource.INSTANCE; // Folia - region threading // Camellia - Make public for : Gale: Optimize random calls in chunk ticking
+ public final io.papermc.paper.threadedregions.util.SimpleThreadLocalRandomSource simpleRandom = io.papermc.paper.threadedregions.util.SimpleThreadLocalRandomSource.INSTANCE; // Folia - region threading // Shiroha - Make public for : Gale: Optimize random calls in chunk ticking
private void optimiseRandomTick(final LevelChunk chunk, final int tickSpeed) {
final LevelChunkSection[] sections = chunk.getSections();
@@ -17,7 +17,7 @@ index 8b778744a5f01943976f180ad340a1cbce7db506..f3e514d801ab14d3baaf1943b7cbca1b
}
public static void write(final ByteBuf output, final CharSequence value, final int maxLength) {
+ // Camellia start - Krypton optimizations
+ // Shiroha start - Krypton optimizations
+ if (true) {
+ if (value.length() > maxLength) {
+ throw new EncoderException("String too big (was " + value.length() + " characters, max " + maxLength + ")");
@@ -32,7 +32,7 @@ index 8b778744a5f01943976f180ad340a1cbce7db506..f3e514d801ab14d3baaf1943b7cbca1b
+ }
+ return;
+ }
+ // Camellia end
+ // Shiroha end
if (value.length() > maxLength) {
throw new EncoderException("String too big (was " + value.length() + " characters, max " + maxLength + ")");
}
@@ -45,8 +45,8 @@ index 1428ce80e8316a24cfca7b6aafdea8588a5a790e..740182c0b1c6918e81a45dddba1c4f48
output.writeShort(s);
} else {
- writeSlow(output, value);
+ // writeSlow(output, value); // Camellia - Krypton optimizations
+ writeVarIntFull(output, value); // Camellia - Krypton optimizations
+ // writeSlow(output, value); // Shiroha - Krypton optimizations
+ writeVarIntFull(output, value); // Shiroha - Krypton optimizations
}
return output;
}
@@ -54,7 +54,7 @@ index 1428ce80e8316a24cfca7b6aafdea8588a5a790e..740182c0b1c6918e81a45dddba1c4f48
output.writeByte(value);
return output;
}
+ // Camellia start - Krypton optimizations
+ // Shiroha start - Krypton optimizations
+ private static void writeVarIntFull(ByteBuf buf, int value) {
+ // See https://steinborn.me/posts/performance/how-fast-can-you-write-a-varint/
+ if ((value & (0xFFFFFFFF << 7)) == 0) {
@@ -76,5 +76,5 @@ index 1428ce80e8316a24cfca7b6aafdea8588a5a790e..740182c0b1c6918e81a45dddba1c4f48
+ buf.writeByte(value >>> 28);
+ }
+ }
+ // Camellia end
+ // Shiroha end
}
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Wed, 8 Jul 2026 18:15:19 +0800
Subject: [PATCH] Rebrand to Camellia
Subject: [PATCH] Rebrand to Shiroha
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
@@ -13,7 +13,7 @@ index 08745a35b1ce8cc56d970472088de3cd17b9e43a..287cff1f4d994584457f00b1e42f283e
// Only start Metrics, if it's enabled in the config
if (config.getBoolean("enabled", true)) {
- Metrics metrics = new Metrics("Folia", serverUUID, logFailedRequests, Bukkit.getLogger()); // Folia - we have our own bstats page
+ Metrics metrics = new Metrics("Camellia", serverUUID, logFailedRequests, Bukkit.getLogger()); // Folia - we have our own bstats page // Camellia - Rebrand to Camellia
+ Metrics metrics = new Metrics("Camellia", serverUUID, logFailedRequests, Bukkit.getLogger()); // Folia - we have our own bstats page // Shiroha - Rebrand to Shiroha
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
String minecraftVersion = Bukkit.getVersion();
@@ -22,12 +22,12 @@ index 08745a35b1ce8cc56d970472088de3cd17b9e43a..287cff1f4d994584457f00b1e42f283e
if (implVersion != null) {
final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1);
- paperVersion = "git-Folia-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Folia - we have our own bstats page
+ paperVersion = "git-Camellia-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Folia - we have our own bstats page // Camellia - Rebrand to Camellia
+ paperVersion = "git-Camellia-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Folia - we have our own bstats page // Shiroha - Rebrand to Shiroha
} else {
paperVersion = "unknown";
}
- metrics.addCustomChart(new Metrics.SimplePie("folia_version", () -> paperVersion)); // Folia - we have our own bstats page
+ metrics.addCustomChart(new Metrics.SimplePie("camellia_version", () -> paperVersion)); // Folia - we have our own bstats page // Camellia - Rebrand to Camellia
+ metrics.addCustomChart(new Metrics.SimplePie("camellia_version", () -> paperVersion)); // Folia - we have our own bstats page // Shiroha - Rebrand to Shiroha
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
Map<String, Map<String, Integer>> map = new HashMap<>();
@@ -41,8 +41,8 @@ index 30815c8970b1f1c88a3c7bb5fd36efd915f1687d..05f159bb5a8499f8957367ed11a9f110
private static final int DISTANCE_UNKNOWN = -2;
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads/folia"; // Folia
- private static final String REPOSITORY = "PaperMC/Folia"; // Folia
+ private static final String DOWNLOAD_PAGE = "https://github.com/MonnaiRealms/Camellia"; // Folia // Camellia - Rebrand to Camellia
+ private static final String REPOSITORY = "MonnaiRealms/Camellia"; // Folia // Camellia - Rebrand to Camellia
+ private static final String DOWNLOAD_PAGE = "https://github.com/MonnaiRealms/Camellia"; // Folia // Shiroha - Rebrand to Shiroha
+ private static final String REPOSITORY = "MonnaiRealms/Camellia"; // Folia // Shiroha - Rebrand to Shiroha
private static final ServerBuildInfo BUILD_INFO = ServerBuildInfo.buildInfo();
private static final String USER_AGENT = BUILD_INFO.brandName() + "/" + BUILD_INFO.asString(VERSION_SIMPLE) + " (https://papermc.io)";
private static final Gson GSON = new Gson();
@@ -51,7 +51,7 @@ index 30815c8970b1f1c88a3c7bb5fd36efd915f1687d..05f159bb5a8499f8957367ed11a9f110
} else {
final Optional<MinecraftVersionFetcher> apiResult = fetchMinecraftVersionList();
- if (buildNumber.isPresent()) {
+ if (buildNumber.isPresent() && false) { // Camellia - Rebrand to Camellia - we do not have a version manager api currently, disable it
+ if (buildNumber.isPresent() && false) { // Shiroha - Rebrand to Shiroha - we do not have a version manager api currently, disable it
distance = fetchDistanceFromSiteApi(buildNumber.getAsInt());
} else {
final Optional<String> gitBranch = BUILD_INFO.gitBranch();
@@ -60,7 +60,7 @@ index 30815c8970b1f1c88a3c7bb5fd36efd915f1687d..05f159bb5a8499f8957367ed11a9f110
final OptionalInt buildNumber = PaperVersionFetcher.BUILD_INFO.buildNumber();
- if (buildNumber.isPresent()) {
+ if (buildNumber.isPresent() && false) { // Camellia - Rebrand to Camellia - we do not have a version manager api currently, disable it
+ if (buildNumber.isPresent() && false) { // Shiroha - Rebrand to Shiroha - we do not have a version manager api currently, disable it
distance = fetchDistanceFromSiteApi(buildNumber.getAsInt());
} else {
final Optional<String> gitBranch = PaperVersionFetcher.BUILD_INFO.gitBranch();
@@ -72,7 +72,7 @@ index 10a0be7a4db1a51579d113d279af7a9effe7f438..45cf7c5c9a4de2c7422e4d9c27fa0064
private static final String ATTRIBUTE_GIT_COMMIT = "Git-Commit";
private static final String BRAND_PAPER_NAME = "Paper";
+ private static final String BRAND_CAMELLIA_NAME = "Camellia"; // Camellia - Rebrand to Camellia
+ private static final String BRAND_CAMELLIA_NAME = "Camellia"; // Shiroha - Rebrand to Shiroha
private static final String BUILD_DEV = "DEV";
@@ -81,10 +81,10 @@ index 10a0be7a4db1a51579d113d279af7a9effe7f438..45cf7c5c9a4de2c7422e4d9c27fa0064
getManifestAttribute(manifest, ATTRIBUTE_BRAND_ID)
.map(Key::key)
- .orElse(Key.key("papermc", "folia")), // Folia
+ .orElse(BRAND_CAMELLIA_ID), // Folia // Camellia - Rebrand to Camellia
+ .orElse(BRAND_CAMELLIA_ID), // Folia // Shiroha - Rebrand to Shiroha
getManifestAttribute(manifest, ATTRIBUTE_BRAND_NAME)
- .orElse("Folia"), // Folia
+ .orElse(BRAND_CAMELLIA_NAME), // Folia // Camellia - Rebrand to Camellia
+ .orElse(BRAND_CAMELLIA_NAME), // Folia // Shiroha - Rebrand to Shiroha
SharedConstants.getCurrentVersion().id(),
SharedConstants.getCurrentVersion().name(),
getManifestAttribute(manifest, ATTRIBUTE_BUILD_NUMBER)
@@ -93,7 +93,7 @@ index 10a0be7a4db1a51579d113d279af7a9effe7f438..45cf7c5c9a4de2c7422e4d9c27fa0064
@Override
public boolean isBrandCompatible(final @NotNull Key brandId) {
- return brandId.equals(this.brandId);
+ return brandId.equals(this.brandId) || brandId.equals(BRAND_PAPER_ID) || brandId.equals(BRAND_FOLIA_ID); // Camellia - Rebrand to Camellia
+ return brandId.equals(this.brandId) || brandId.equals(BRAND_PAPER_ID) || brandId.equals(BRAND_FOLIA_ID); // Shiroha - Rebrand to Shiroha
}
@Override
@@ -106,10 +106,10 @@ index 5607f4cc8ca2f620461eb5e97d01d9db0d6b2303..5a86fa68007bc00fcf3ceda2d2492322
logger.log(Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once");
logger.log(Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes");
- logger.log(Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues");
+ logger.log(Level.SEVERE, "If you are unsure or still think this is a Camellia bug, please report this to https://github.com/MonnaiRealms/Camellia/issues"); // Camellia - Rebrand to Camellia
+ logger.log(Level.SEVERE, "If you are unsure or still think this is a Camellia bug, please report this to https://github.com/MonnaiRealms/Camellia/issues"); // Shiroha - Rebrand to Shiroha
logger.log(Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports");
- logger.log(Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion());
+ logger.log(Level.SEVERE, "Camellia version: " + Bukkit.getServer().getVersion()); // Camellia - Rebrand to Camellia
+ logger.log(Level.SEVERE, "Camellia version: " + Bukkit.getServer().getVersion()); // Shiroha - Rebrand to Shiroha
if (net.minecraft.world.level.Level.lastPhysicsProblem != null) {
logger.log(Level.SEVERE, "------------------------------");
@@ -13,7 +13,7 @@ index 70e21e1fc337c6ea40e64020fa1832d1630cae97..f4af14dfd277fa0261a6e0623f8d11f2
static final Color DEFAULT_LEATHER_COLOR = Color.fromRGB(0xA06540);
private static final CraftItemFactory instance;
- private static final RandomSource randomSource = RandomSource.create();
+ private static final RandomSource randomSource = io.papermc.paper.threadedregions.util.ThreadLocalRandomSource.INSTANCE; // Camellia - Correct thread unsafe random sources
+ private static final RandomSource randomSource = io.papermc.paper.threadedregions.util.ThreadLocalRandomSource.INSTANCE; // Shiroha - Correct thread unsafe random sources
static {
instance = new CraftItemFactory();
@@ -12,7 +12,7 @@ index 9d0dc8815842a0583b212891680bd0c6461c30b9..9968f5064571b0917c8897c23fe06a14
@Override
public void reload() {
+ if (true) throw new UnsupportedOperationException(); // Camellia - Force disable reload command and api
+ if (true) throw new UnsupportedOperationException(); // Shiroha - Force disable reload command and api
// Paper start - lifecycle events
if (io.papermc.paper.plugin.lifecycle.event.LifecycleEventRunner.INSTANCE.blocksPluginReloading()) {
throw new IllegalStateException(org.bukkit.command.defaults.ReloadCommand.RELOADING_DISABLED_MESSAGE);
@@ -13,7 +13,7 @@ index 9661f033bbb2c00073f1c891e1411c2a9943a37a..70fccec55edb67c24c7ecbf3687682de
final PluginMeta config = type.getConfig(file);
- if ((config.getName().equals("spark") && config.getMainClass().equals("me.lucko.spark.bukkit.BukkitSparkPlugin")) && !SparksFly.isPluginPreferred()) {
+ if ((config.getName().equals("spark") && config.getMainClass().equals("me.lucko.spark.bukkit.BukkitSparkPlugin")) && !SparksFly.isPluginPreferred() && false) { // Camellia - Force disable builtin spark
+ if ((config.getName().equals("spark") && config.getMainClass().equals("me.lucko.spark.bukkit.BukkitSparkPlugin")) && !SparksFly.isPluginPreferred() && false) { // Shiroha - Force disable builtin spark
LOGGER.info("The spark plugin will not be loaded as this server bundles the spark profiler.");
return;
}
@@ -26,7 +26,7 @@ index 9968f5064571b0917c8897c23fe06a148c63a305..3c46e2cc23ac57df52996e3d2c5ae416
private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher();
private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer;
- public final io.papermc.paper.SparksFly spark;
+ public io.papermc.paper.SparksFly spark; // Paper - spark // Camellia - Force disable builtin spark
+ public io.papermc.paper.SparksFly spark; // Paper - spark // Shiroha - Force disable builtin spark
private final ServerConfiguration serverConfig = new PaperServerConfiguration();
// Paper start - Folia region threading API
@@ -35,7 +35,7 @@ index 9968f5064571b0917c8897c23fe06a148c63a305..3c46e2cc23ac57df52996e3d2c5ae416
this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
- this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark
+ if (false) this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark // Shiroha - Force disable builtin spark
}
public boolean getCommandBlockOverride(String command) {
@@ -44,7 +44,7 @@ index 9968f5064571b0917c8897c23fe06a148c63a305..3c46e2cc23ac57df52996e3d2c5ae416
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
- this.spark.registerCommandBeforePlugins(this); // Paper - spark
+ if (false) this.spark.registerCommandBeforePlugins(this); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.spark.registerCommandBeforePlugins(this); // Paper - spark // Shiroha - Force disable builtin spark
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
@@ -53,7 +53,7 @@ index 9968f5064571b0917c8897c23fe06a148c63a305..3c46e2cc23ac57df52996e3d2c5ae416
this.enablePlugins(PluginLoadOrder.STARTUP);
this.enablePlugins(PluginLoadOrder.POSTWORLD);
- this.spark.registerCommandAfterPlugins(this); // Paper - spark
+ if (false) this.spark.registerCommandAfterPlugins(this); // Paper - spark // Camellia - Force disable builtin spark
+ if (false) this.spark.registerCommandAfterPlugins(this); // Paper - spark // Shiroha - Force disable builtin spark
// Paper start - brigadier command API
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // to clear invalid state for event fire below
io.papermc.paper.plugin.lifecycle.event.LifecycleEventRunner.INSTANCE.callReloadableRegistrarEvent(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, io.papermc.paper.command.brigadier.PaperCommands.INSTANCE, org.bukkit.plugin.Plugin.class, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.RELOAD); // call commands event for regular plugins
@@ -13,7 +13,7 @@ index 13b03dab807c5d83e086993af705e1d9a2676b4d..83894904de29c01a4e105c1fae625f91
PaperServerListPingEventImpl(MinecraftServer server, StatusClient client, int protocolVersion, @Nullable CachedServerIcon icon) {
super(client, server.motd(), server.getPlayerCount(), server.getMaxPlayers(),
- server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon);
+ moe.monnairealms.camellia.config.modules.misc.ServerModNameConfig.fakeVanilla ? server.getServerVersion() : server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon); // Camellia - Add config for server mod name
+ moe.monnairealms.camellia.config.modules.misc.ServerModNameConfig.fakeVanilla ? server.getServerVersion() : server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon); // Shiroha - Add config for server mod name
this.server = server;
}
@@ -13,7 +13,7 @@ index 6c74787321748702022787b65ff5465f8bcec4ad..5d7a4f42ed274d78e79f0d4e5dd974ff
@Deprecated
public static void ensureTickThread(final String reason) {
- if (!isTickThread()) {
+ if (!isTickThread() && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Camellia - Add config to disable async catchers
+ if (!isTickThread() && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Shiroha - Add config to disable async catchers
LOGGER.error("Thread failed main thread check: " + reason + ", context=" + getThreadContext(), new Throwable());
throw new IllegalStateException(reason);
}
@@ -21,7 +21,7 @@ index 6c74787321748702022787b65ff5465f8bcec4ad..5d7a4f42ed274d78e79f0d4e5dd974ff
public static void ensureTickThread(final Level world, final BlockPos pos, final String reason) {
- if (!isTickThreadFor(world, pos)) {
+ if (!isTickThreadFor(world, pos) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Camellia - Add config to disable async catchers
+ if (!isTickThreadFor(world, pos) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Shiroha - Add config to disable async catchers
final String ex = "Thread failed main thread check: " +
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos;
LOGGER.error(ex, new Throwable());
@@ -30,7 +30,7 @@ index 6c74787321748702022787b65ff5465f8bcec4ad..5d7a4f42ed274d78e79f0d4e5dd974ff
public static void ensureTickThread(final Level world, final BlockPos pos, final int blockRadius, final String reason) {
- if (!isTickThreadFor(world, pos, blockRadius)) {
+ if (!isTickThreadFor(world, pos, blockRadius) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Camellia - Add config to disable async catchers
+ if (!isTickThreadFor(world, pos, blockRadius) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Shiroha - Add config to disable async catchers
final String ex = "Thread failed main thread check: " +
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + ", block_radius=" + blockRadius;
LOGGER.error(ex, new Throwable());
@@ -39,7 +39,7 @@ index 6c74787321748702022787b65ff5465f8bcec4ad..5d7a4f42ed274d78e79f0d4e5dd974ff
public static void ensureTickThread(final Level world, final ChunkPos pos, final String reason) {
- if (!isTickThreadFor(world, pos)) {
+ if (!isTickThreadFor(world, pos) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Camellia - Add config to disable async catchers
+ if (!isTickThreadFor(world, pos) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Shiroha - Add config to disable async catchers
final String ex = "Thread failed main thread check: " +
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + pos;
LOGGER.error(ex, new Throwable());
@@ -48,7 +48,7 @@ index 6c74787321748702022787b65ff5465f8bcec4ad..5d7a4f42ed274d78e79f0d4e5dd974ff
public static void ensureTickThread(final Level world, final int chunkX, final int chunkZ, final String reason) {
- if (!isTickThreadFor(world, chunkX, chunkZ)) {
+ if (!isTickThreadFor(world, chunkX, chunkZ) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Camellia - Add config to disable async catchers
+ if (!isTickThreadFor(world, chunkX, chunkZ) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Shiroha - Add config to disable async catchers
final String ex = "Thread failed main thread check: " +
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + new ChunkPos(chunkX, chunkZ);
LOGGER.error(ex, new Throwable());
@@ -57,7 +57,7 @@ index 6c74787321748702022787b65ff5465f8bcec4ad..5d7a4f42ed274d78e79f0d4e5dd974ff
public static void ensureTickThread(final Entity entity, final String reason) {
- if (!isTickThreadFor(entity)) {
+ if (!isTickThreadFor(entity) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Camellia - Add config to disable async catchers
+ if (!isTickThreadFor(entity) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Shiroha - Add config to disable async catchers
final String ex = "Thread failed main thread check: " +
reason + ", context=" + getThreadContext() + ", entity=" + EntityUtil.dumpEntity(entity);
LOGGER.error(ex, new Throwable());
@@ -66,7 +66,7 @@ index 6c74787321748702022787b65ff5465f8bcec4ad..5d7a4f42ed274d78e79f0d4e5dd974ff
public static void ensureTickThread(final Level world, final AABB aabb, final String reason) {
- if (!isTickThreadFor(world, aabb)) {
+ if (!isTickThreadFor(world, aabb) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Camellia - Add config to disable async catchers
+ if (!isTickThreadFor(world, aabb) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Shiroha - Add config to disable async catchers
final String ex = "Thread failed main thread check: " +
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", aabb=" + aabb;
LOGGER.error(ex, new Throwable());
@@ -75,7 +75,7 @@ index 6c74787321748702022787b65ff5465f8bcec4ad..5d7a4f42ed274d78e79f0d4e5dd974ff
public static void ensureTickThread(final Level world, final double blockX, final double blockZ, final String reason) {
- if (!isTickThreadFor(world, blockX, blockZ)) {
+ if (!isTickThreadFor(world, blockX, blockZ) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Camellia - Add config to disable async catchers
+ if (!isTickThreadFor(world, blockX, blockZ) && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Shiroha - Add config to disable async catchers
final String ex = "Thread failed main thread check: " +
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + new Vec3(blockX, 0.0, blockZ);
LOGGER.error(ex, new Throwable());
@@ -88,7 +88,7 @@ index 7e7a0ed944961af5ab7a49bc659da2862d2e2c82..1dc664a97442744d0a9364805cc6d6c5
public static void catchOp(String reason) {
- if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()) { // Paper - chunk system
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread() && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Paper - chunk system // Camellia - Add config to disable async catchers
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread() && !moe.monnairealms.camellia.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Paper - chunk system // Shiroha - Add config to disable async catchers
MinecraftServer.LOGGER.error("Thread {} failed main thread check: {}", Thread.currentThread().getName(), reason, new Throwable()); // Paper
throw new IllegalStateException("Asynchronous " + reason + "!");
}
@@ -16,7 +16,7 @@ index 6369b13e1fcdbdb25dd9d6e4d3bffdedbee4f739..ea27ce9d08b3b8bbb0cd4918dbf51fd8
public PaperPluginParent build(JarFile file, PaperPluginMeta configuration, Path source) {
// Folia start - block plugins not marked as supported
- if (!configuration.isFoliaSupported()) {
+ if (!configuration.isFoliaSupported() && !moe.monnairealms.camellia.config.modules.unsupported.DisableCheckForFoliaSupported.disableForPaper) { // Camellia - disable check for folia supported
+ if (!configuration.isFoliaSupported() && !moe.monnairealms.camellia.config.modules.unsupported.DisableCheckForFoliaSupported.disableForPaper) { // Shiroha - disable check for folia supported
throw new RuntimeException("Could not load plugin '" + configuration.getDisplayName() + "' as it is not marked as supporting Folia!");
}
// Folia end - block plugins not marked as supported
@@ -29,7 +29,7 @@ index 6ef0042a355c65262bdb89dcf151bd644653216d..7da13c7a2c5303d8f3bee2db4b5b76a1
public SpigotPluginProvider build(JarFile file, PluginDescriptionFile configuration, Path source) throws InvalidDescriptionException {
// Folia start - block plugins not marked as supported
- if (!configuration.isFoliaSupported()) {
+ if (!configuration.isFoliaSupported() && !moe.monnairealms.camellia.config.modules.unsupported.DisableCheckForFoliaSupported.disableForPaper) { // Camellia - disable check for folia supported
+ if (!configuration.isFoliaSupported() && !moe.monnairealms.camellia.config.modules.unsupported.DisableCheckForFoliaSupported.disableForPaper) { // Shiroha - disable check for folia supported
throw new RuntimeException("Could not load plugin '" + configuration.getDisplayName() + "' as it is not marked as supporting Folia!");
}
// Folia end - block plugins not marked as supported
@@ -42,7 +42,7 @@ index 55a095e00bfe15321d8a1d69beb232e9956b0df7..844d6211ae34b3136806b8513e30d48c
// Folia start - block plugins not marked as supported
- if (!descriptionFile.isFoliaSupported()) {
+ if (!descriptionFile.isFoliaSupported() && !moe.monnairealms.camellia.config.modules.unsupported.DisableCheckForFoliaSupported.disableForPaper) { // Camellia - disable check for folia supported
+ if (!descriptionFile.isFoliaSupported() && !moe.monnairealms.camellia.config.modules.unsupported.DisableCheckForFoliaSupported.disableForPaper) { // Shiroha - disable check for folia supported
throw new InvalidPluginException("Plugin " + descriptionFile.getFullName() + " is not marked as supporting regionised multithreading");
}
// Folia end - block plugins not marked as supported
@@ -13,7 +13,7 @@ index b9f788693b0c4be48e8a923a3dec50555d135e7e..1ce8304688ff3751d2de3ada14539842
@Override
public Thread newThread(final Runnable run) {
- final Thread thread = new Thread(run, PlatformHooks.get().getBrand() + " Common Worker #" + this.idGenerator.getAndIncrement());
+ final Thread thread = new Thread(moe.monnairealms.camellia.config.modules.optimizations.CpuAffinityConfig.wrapForChunkSystemWorker(run), PlatformHooks.get().getBrand() + " Common Worker #" + this.idGenerator.getAndIncrement()); // Camellia - Add config for cpu affinity
+ final Thread thread = new Thread(moe.monnairealms.camellia.config.modules.optimizations.CpuAffinityConfig.wrapForChunkSystemWorker(run), PlatformHooks.get().getBrand() + " Common Worker #" + this.idGenerator.getAndIncrement()); // Shiroha - Add config for cpu affinity
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@@ -22,7 +22,7 @@ index b9f788693b0c4be48e8a923a3dec50555d135e7e..1ce8304688ff3751d2de3ada14539842
@Override
public Thread newThread(final Runnable run) {
- final Thread thread = new Thread(run, PlatformHooks.get().getBrand() + " I/O Worker #" + this.idGenerator.getAndIncrement());
+ final Thread thread = new Thread(moe.monnairealms.camellia.config.modules.optimizations.CpuAffinityConfig.wrapForChunkSystemIo(run), PlatformHooks.get().getBrand() + " I/O Worker #" + this.idGenerator.getAndIncrement()); // Camellia - Add config for cpu affinity
+ final Thread thread = new Thread(moe.monnairealms.camellia.config.modules.optimizations.CpuAffinityConfig.wrapForChunkSystemIo(run), PlatformHooks.get().getBrand() + " I/O Worker #" + this.idGenerator.getAndIncrement()); // Shiroha - Add config for cpu affinity
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@@ -12,11 +12,11 @@ index 532076c7358aa355ce5144075fe6bd79de6ef9e6..fa940f0dfc19aa2853b7a0d19743321d
return CraftLocation.toBukkit(pos, world);
}
+ // Camellia start - add BlockPos support
+ // Shiroha start - add BlockPos support
+ public static Location toLocation(Level world, BlockPos pos) {
+ return CraftLocation.toBukkit(pos, world);
+ }
+ // Camellia end - add BlockPos support
+ // Shiroha end - add BlockPos support
+
/**
* Converts a NMS World/Vector to Bukkit Location