Implement config hooks in PaperHooks

This commit is contained in:
Spottedleaf 2024-10-24 08:36:07 -07:00
parent 8e569ba62a
commit 3b316215d7
4 changed files with 19 additions and 28 deletions

View File

@ -3,16 +3,8 @@ https://github.com/Tuinity/Moonrise/compare/6a2c6d27df11d417c1fefa749109d8e87599
need to compare the diffs need to compare the diffs
add notes to moonrise patch:
- implemented fast palette patch
- implemented better bitstorage magic patch
- implemented blockstate property patch (replaced old paper one)
- implemented fluid patch
todo: todo:
- double check that the misc changes commit on dev/1.21.2 moonrise is applied - double check that the misc changes commit on dev/1.21.2 moonrise is applied
- implement platformhooks
- in ChunkEntitySlices, implement modifySavedEntities() by copying from old - in ChunkEntitySlices, implement modifySavedEntities() by copying from old
- implement PlayerChunkUnloadEvent in PlatformHooks#onChunkUnWatch - implement PlayerChunkUnloadEvent in PlatformHooks#onChunkUnWatch
- make sure chunk pos is passed in PlatformHooks#postLoadProtoChunk - make sure chunk pos is passed in PlatformHooks#postLoadProtoChunk
@ -32,5 +24,4 @@ todo:
- implement starlight.ChunkSerializerMixin diff from reference - implement starlight.ChunkSerializerMixin diff from reference
- implement starlight.SerializableChunkData$SectionData diff from reference - implement starlight.SerializableChunkData$SectionData diff from reference
- implement starlight.SerializableChunkDataMixin diff from reference - implement starlight.SerializableChunkDataMixin diff from reference
- unfuck the chtunk system config diff
- chunk system: move get entity lookup reroute into the folia scheduler api patch - chunk system: move get entity lookup reroute into the folia scheduler api patch

View File

@ -6,7 +6,7 @@ Subject: [PATCH] fixup! MC Utils
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java b/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java diff --git a/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java b/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..deb64f7ebebcf6de91ffe0542d6b449a4db64da0 index 0000000000000000000000000000000000000000..6c98d420ea84c10ef4f15d4deb3f04e610ed8548
--- /dev/null --- /dev/null
+++ b/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java
@@ -0,0 +1,117 @@ @@ -0,0 +1,117 @@
@ -91,9 +91,9 @@ index 0000000000000000000000000000000000000000..deb64f7ebebcf6de91ffe0542d6b449a
+ +
+ public int configPlayerMaxConcurrentGens(); + public int configPlayerMaxConcurrentGens();
+ +
+ public long configAutoSaveInterval(); + public long configAutoSaveInterval(final ServerLevel world);
+ +
+ public int configMaxAutoSavePerTick(); + public int configMaxAutoSavePerTick(final ServerLevel world);
+ +
+ public boolean configFixMC159283(); + public boolean configFixMC159283();
+ +
@ -1026,7 +1026,7 @@ index af9623240ff2d389aa7090623f507720e7dbab7d..efda2688ae1254a82ba7f6bf8bf597ef
public static int getMaxLightSection(final LevelHeightAccessor world) { public static int getMaxLightSection(final LevelHeightAccessor world) {
diff --git a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java diff --git a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ee514a767f69de69d86e1e88d70fe37c4ab84277 index 0000000000000000000000000000000000000000..1aa6be257ce594d7a69fdff008cd29014a04fd75
--- /dev/null --- /dev/null
+++ b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java +++ b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java
@@ -0,0 +1,209 @@ @@ -0,0 +1,209 @@
@ -1153,42 +1153,42 @@ index 0000000000000000000000000000000000000000..ee514a767f69de69d86e1e88d70fe37c
+ +
+ @Override + @Override
+ public boolean configAutoConfigSendDistance() { + public boolean configAutoConfigSendDistance() {
+ + return io.papermc.paper.configuration.GlobalConfiguration.get().chunkLoadingAdvanced.autoConfigSendDistance;
+ } + }
+ +
+ @Override + @Override
+ public double configPlayerMaxLoadRate() { + public double configPlayerMaxLoadRate() {
+ + return io.papermc.paper.configuration.GlobalConfiguration.get().chunkLoadingBasic.playerMaxChunkLoadRate;
+ } + }
+ +
+ @Override + @Override
+ public double configPlayerMaxGenRate() { + public double configPlayerMaxGenRate() {
+ + return io.papermc.paper.configuration.GlobalConfiguration.get().chunkLoadingBasic.playerMaxChunkGenerateRate;
+ } + }
+ +
+ @Override + @Override
+ public double configPlayerMaxSendRate() { + public double configPlayerMaxSendRate() {
+ + return io.papermc.paper.configuration.GlobalConfiguration.get().chunkLoadingBasic.playerMaxChunkSendRate;
+ } + }
+ +
+ @Override + @Override
+ public int configPlayerMaxConcurrentLoads() { + public int configPlayerMaxConcurrentLoads() {
+ + return io.papermc.paper.configuration.GlobalConfiguration.get().chunkLoadingAdvanced.playerMaxConcurrentChunkLoads;
+ } + }
+ +
+ @Override + @Override
+ public int configPlayerMaxConcurrentGens() { + public int configPlayerMaxConcurrentGens() {
+ + return io.papermc.paper.configuration.GlobalConfiguration.get().chunkLoadingAdvanced.playerMaxConcurrentChunkGenerates;
+ } + }
+ +
+ @Override + @Override
+ public long configAutoSaveInterval() { + public long configAutoSaveInterval(final ServerLevel world) {
+ + return world.paperConfig().chunks.autoSaveInterval.value();
+ } + }
+ +
+ @Override + @Override
+ public int configMaxAutoSavePerTick() { + public int configMaxAutoSavePerTick(final ServerLevel world) {
+ + return world.paperConfig().chunks.maxAutoSaveChunksPerTick;
+ } + }
+ +
+ @Override + @Override

View File

@ -30187,7 +30187,7 @@ index 0000000000000000000000000000000000000000..5a6536377c9c1e1753e930ff2a6bb98e
+ } + }
+} +}
diff --git a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java diff --git a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java
index ee514a767f69de69d86e1e88d70fe37c4ab84277..be60439c43b887f0143e7713689fd2773066ba73 100644 index 1aa6be257ce594d7a69fdff008cd29014a04fd75..c8f2457ab3b28f2c3a6b500bcea40261669c24a4 100644
--- a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java --- a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java
+++ b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java +++ b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java
@@ -172,6 +172,43 @@ public final class PaperHooks implements PlatformHooks { @@ -172,6 +172,43 @@ public final class PaperHooks implements PlatformHooks {

View File

@ -365,7 +365,7 @@ index 94bba2b71918d79f54b3e28c35e76098ba0afd8c..fc029c8fb22a7c8eeb23bfc171812f6d
private ChunkSystem() {} private ChunkSystem() {}
diff --git a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java diff --git a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java
index be60439c43b887f0143e7713689fd2773066ba73..dc17aa5a0937c13d431e41779f241f2e81b11656 100644 index c8f2457ab3b28f2c3a6b500bcea40261669c24a4..ca8b6a926dfff3fdd6b04228809a4480366120b2 100644
--- a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java --- a/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java
+++ b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java +++ b/src/main/java/ca/spottedleaf/moonrise/paper/PaperHooks.java
@@ -236,7 +236,7 @@ public final class PaperHooks implements PlatformHooks { @@ -236,7 +236,7 @@ public final class PaperHooks implements PlatformHooks {
@ -6782,7 +6782,7 @@ index 0000000000000000000000000000000000000000..7eafc5b7cba23d8dec92ecc1050afe3f
\ No newline at end of file \ No newline at end of file
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..f98df65eaed2abedc66f3a49790e0cfb65354ed9 index 0000000000000000000000000000000000000000..a0e5fc2eff605e17704f0726d20e79cbb3d88d6d
--- /dev/null --- /dev/null
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
@@ -0,0 +1,1455 @@ @@ -0,0 +1,1455 @@
@ -7019,8 +7019,8 @@ index 0000000000000000000000000000000000000000..f98df65eaed2abedc66f3a49790e0cfb
+ public void autoSave() { + public void autoSave() {
+ final List<NewChunkHolder> reschedule = new ArrayList<>(); + final List<NewChunkHolder> reschedule = new ArrayList<>();
+ final long currentTick = this.currentTick; + final long currentTick = this.currentTick;
+ final long maxSaveTime = currentTick - Math.max(1L, PlatformHooks.get().configAutoSaveInterval()); + final long maxSaveTime = currentTick - Math.max(1L, PlatformHooks.get().configAutoSaveInterval(this.world));
+ final int maxToSave = PlatformHooks.get().configMaxAutoSavePerTick(); + final int maxToSave = PlatformHooks.get().configMaxAutoSavePerTick(this.world);
+ for (int autoSaved = 0; autoSaved < maxToSave && !this.autoSaveQueue.isEmpty();) { + for (int autoSaved = 0; autoSaved < maxToSave && !this.autoSaveQueue.isEmpty();) {
+ final NewChunkHolder holder = this.autoSaveQueue.first(); + final NewChunkHolder holder = this.autoSaveQueue.first();
+ +