From 90676f6e55d49ea5313c1aa3e9fbab749a31a462 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Thu, 17 Oct 2024 19:21:52 -0700 Subject: [PATCH] Update to 1.21.2-rc1 --- fabric/build.gradle | 2 +- gradle.properties | 9 +++--- .../resources/META-INF/neoforge.mods.toml | 2 +- .../mixin/chunk_system/ChunkMapMixin.java | 28 +++++++++++++++++++ .../mixin/chunk_system/LevelChunkMixin.java | 14 ++++++---- .../scheduling/NewChunkHolder.java | 2 +- .../scheduling/task/ChunkFullTask.java | 1 + src/main/resources/moonrise.accesswidener | 3 +- 8 files changed, 48 insertions(+), 13 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 417dbbf8..ea11af43 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -22,7 +22,7 @@ dependencies { modImplementation "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}" include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}" - modImplementation "com.terraformersmc:modmenu:11.0.1" + modImplementation "com.terraformersmc:modmenu:${rootProject.modmenu_version}" modImplementation fabricApiLibs.fabric.api include fabricApiLibs.command.api.v2 diff --git a/gradle.properties b/gradle.properties index 8d942c33..ad382c20 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,13 +3,14 @@ org.gradle.jvmargs=-Xmx2G org.gradle.daemon=false # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.21.2-pre1 +minecraft_version=1.21.2-rc1 loader_version=0.16.7 -supported_minecraft_versions=1.21.2-pre1 -neoforge_version=21.2.0-alpha.1.21.2-pre1.20241015.021437 +supported_minecraft_versions=1.21.2-rc1 +neoforge_version=21.2.0-alpha.1.21.2-rc1.20241018.015152 snakeyaml_version=2.2 concurrentutil_version=0.0.2-SNAPSHOT -cloth_version=15.0.128 +cloth_version=15.0.140 +modmenu_version=12.0.0-beta.1 lithium_version=mc1.21.1-0.13.1 # Mod Properties mod_version=0.1.0-SNAPSHOT diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 5f425e8f..cfee7e66 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -24,7 +24,7 @@ side = "BOTH" [[dependencies.moonrise]] modId = "minecraft" type = "required" -versionRange = "[1.21.2,1.21.3)" +versionRange = "(1.21.1,1.21.3)" ordering = "NONE" side = "BOTH" diff --git a/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/ChunkMapMixin.java b/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/ChunkMapMixin.java index a894b9e9..6ea51c2b 100644 --- a/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/ChunkMapMixin.java +++ b/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/ChunkMapMixin.java @@ -11,8 +11,10 @@ import com.mojang.datafixers.DataFixer; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; import java.util.concurrent.Executor; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.IntConsumer; import java.util.function.Supplier; +import it.unimi.dsi.fastutil.longs.LongSet; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.StreamTagVisitor; import net.minecraft.server.level.ChunkGenerationTask; @@ -95,6 +97,12 @@ abstract class ChunkMapMixin extends ChunkStorage implements ChunkSystemChunkMap @Shadow private Queue unloadQueue; + @Shadow + private LongSet chunksToEagerlySave; + + @Shadow + private AtomicInteger activeChunkWrites; + public ChunkMapMixin(RegionStorageInfo regionStorageInfo, Path path, DataFixer dataFixer, boolean bl) { super(regionStorageInfo, path, dataFixer, bl); } @@ -129,6 +137,8 @@ private void constructor( this.lightTaskDispatcher = null; this.pendingGenerationTasks = null; this.unloadQueue = null; + this.chunksToEagerlySave = null; + this.activeChunkWrites = null; // Dummy impl for mods that try to loadAsync directly this.worker = new IOWorker( @@ -180,6 +190,15 @@ public RegionStorageInfo storageInfo() { }; } + /** + * @reason This map is not needed, we maintain our own ordered set of chunks to autosave. + * @author Spottedleaf + */ + @Overwrite + private void setChunkUnsaved(final ChunkPos pos) { + + } + /** * @reason Route to new chunk system hooks * @author Spottedleaf @@ -314,6 +333,15 @@ public void processUnloads(final BooleanSupplier shouldKeepTicking) { ((ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.autoSave(); } + /** + * @reason Destroy old chunk system hooks + * @author Spottedleaf + */ + @Overwrite + private void saveChunksEagerly(final BooleanSupplier hasTime) { + throw new UnsupportedOperationException(); + } + /** * @reason Destroy old chunk system hooks * @author Spottedleaf diff --git a/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/LevelChunkMixin.java b/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/LevelChunkMixin.java index b6b9a6a4..bb44d7c0 100644 --- a/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/LevelChunkMixin.java +++ b/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/LevelChunkMixin.java @@ -93,11 +93,15 @@ public boolean isUnsaved() { } @Override - public void setUnsaved(final boolean needsSaving) { - if (!needsSaving) { - ((ChunkSystemLevelChunkTicks)this.blockTicks).moonrise$clearDirty(); - ((ChunkSystemLevelChunkTicks)this.fluidTicks).moonrise$clearDirty(); + public boolean tryMarkSaved() { + if (!this.isUnsaved()) { + return false; } - super.setUnsaved(needsSaving); + ((ChunkSystemLevelChunkTicks)this.blockTicks).moonrise$clearDirty(); + ((ChunkSystemLevelChunkTicks)this.fluidTicks).moonrise$clearDirty(); + + super.tryMarkSaved(); + + return true; } } diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java index 66e99477..381631e4 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java @@ -1751,7 +1751,7 @@ private boolean saveChunk(final ChunkAccess chunk, final boolean unloading) { final SerializableChunkData chunkData = SerializableChunkData.copyOf(this.world, chunk); PlatformHooks.get().chunkSyncSave(this.world, chunk, chunkData); - chunk.setUnsaved(false); + chunk.tryMarkSaved(); final CallbackCompletable completable = new CallbackCompletable<>(); diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java index bbc700df..98382575 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java @@ -85,6 +85,7 @@ public void run() { chunk.setLoaded(true); chunk.registerAllBlockEntitiesAfterLevelLoad(); chunk.registerTickContainerInLevel(this.world); + chunk.setUnsavedListener(this.world.getChunkSource().chunkMap.worldGenContext.unsavedListener()); platformHooks.chunkFullStatusComplete(chunk, (ProtoChunk)this.fromChunk); } finally { platformHooks.setCurrentlyLoading(this.chunkHolder.vanillaChunkHolder, null); diff --git a/src/main/resources/moonrise.accesswidener b/src/main/resources/moonrise.accesswidener index 2462a8fb..cdfe14d6 100644 --- a/src/main/resources/moonrise.accesswidener +++ b/src/main/resources/moonrise.accesswidener @@ -47,7 +47,8 @@ accessible field net/minecraft/server/level/ChunkMap worldGenContext Lnet/minecr accessible field net/minecraft/server/level/ChunkMap tickingGenerated Ljava/util/concurrent/atomic/AtomicInteger; accessible field net/minecraft/server/level/ChunkMap progressListener Lnet/minecraft/server/level/progress/ChunkProgressListener; accessible method net/minecraft/server/level/ChunkMap playerIsCloseEnoughForSpawning (Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/ChunkPos;)Z - +mutable field net/minecraft/server/level/ChunkMap chunksToEagerlySave Lit/unimi/dsi/fastutil/longs/LongSet; +mutable field net/minecraft/server/level/ChunkMap activeChunkWrites Ljava/util/concurrent/atomic/AtomicInteger; # ChunkLevel accessible field net/minecraft/server/level/ChunkLevel FULL_CHUNK_LEVEL I