Skip to content

Commit

Permalink
Update to 1.21.2-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
Spottedleaf committed Oct 18, 2024
1 parent 59709fc commit 90676f6
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,6 +97,12 @@ abstract class ChunkMapMixin extends ChunkStorage implements ChunkSystemChunkMap
@Shadow
private Queue<Runnable> unloadQueue;

@Shadow
private LongSet chunksToEagerlySave;

@Shadow
private AtomicInteger activeChunkWrites;

public ChunkMapMixin(RegionStorageInfo regionStorageInfo, Path path, DataFixer dataFixer, boolean bl) {
super(regionStorageInfo, path, dataFixer, bl);
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompoundTag> completable = new CallbackCompletable<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/moonrise.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90676f6

Please sign in to comment.