-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: strict detection for scheduled tick access
- Loading branch information
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
patches/main/0008-new-strict-detection-for-scheduled-tick-access.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: ishland <[email protected]> | ||
Date: Tue, 24 Dec 2024 17:59:16 +0800 | ||
Subject: [PATCH] new: strict detection for scheduled tick access | ||
|
||
|
||
diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading_detections/readonly_protection/MixinChunkRegion.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading_detections/readonly_protection/MixinChunkRegion.java | ||
new file mode 100644 | ||
index 00000000..d1c5fae4 | ||
--- /dev/null | ||
+++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading_detections/readonly_protection/MixinChunkRegion.java | ||
@@ -0,0 +1,49 @@ | ||
+package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading_detections.readonly_protection; | ||
+ | ||
+import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; | ||
+import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
+import net.minecraft.fluid.Fluid; | ||
+import net.minecraft.util.math.BlockPos; | ||
+import net.minecraft.util.math.ChunkPos; | ||
+import net.minecraft.world.ChunkRegion; | ||
+import net.minecraft.world.chunk.Chunk; | ||
+import net.minecraft.world.chunk.ChunkGenerationStep; | ||
+import net.minecraft.world.tick.BasicTickScheduler; | ||
+import net.minecraft.world.tick.EmptyTickSchedulers; | ||
+import org.slf4j.Logger; | ||
+import org.spongepowered.asm.mixin.Final; | ||
+import org.spongepowered.asm.mixin.Mixin; | ||
+import org.spongepowered.asm.mixin.Shadow; | ||
+ | ||
+@Mixin(ChunkRegion.class) | ||
+public abstract class MixinChunkRegion { | ||
+ | ||
+ @Shadow public abstract boolean isValidForSetBlock(BlockPos pos); | ||
+ | ||
+ @Shadow @Final private static Logger LOGGER; | ||
+ | ||
+ @Shadow @Final private ChunkGenerationStep generationStep; | ||
+ | ||
+ @Shadow @Final private Chunk centerPos; | ||
+ | ||
+ @WrapMethod(method = "method_14340") | ||
+ private BasicTickScheduler<BlockPos> wrapBlockScheduledTick(BlockPos pos, Operation<BasicTickScheduler<BlockPos>> original) { | ||
+ if (this.isValidForSetBlock(pos)) { | ||
+ return original.call(pos); | ||
+ } else { | ||
+ LOGGER.warn("Detected block scheduled tick access in a far chunk {}, pos: {}, status: {}, currently generating: {}", new ChunkPos(pos), pos, this.generationStep.targetStatus(), this.centerPos.getPos()); | ||
+ return EmptyTickSchedulers.getReadOnlyTickScheduler(); | ||
+ } | ||
+ } | ||
+ | ||
+ @WrapMethod(method = "method_14337") | ||
+ private BasicTickScheduler<Fluid> wrapFluidScheduledTick(BlockPos pos, Operation<BasicTickScheduler<Fluid>> original) { | ||
+ if (this.isValidForSetBlock(pos)) { | ||
+ return original.call(pos); | ||
+ } else { | ||
+ LOGGER.warn("Detected fluid scheduled tick access in a far chunk {}, pos: {}, status: {}, currently generating: {}", new ChunkPos(pos), pos, this.generationStep.targetStatus(), this.centerPos.getPos()); | ||
+ return EmptyTickSchedulers.getReadOnlyTickScheduler(); | ||
+ } | ||
+ } | ||
+ | ||
+} | ||
diff --git a/c2me-fixes-worldgen-threading-issues/src/main/resources/c2me-fixes-worldgen-threading-issues.mixins.json b/c2me-fixes-worldgen-threading-issues/src/main/resources/c2me-fixes-worldgen-threading-issues.mixins.json | ||
index b0ed8d8f..5979b61c 100644 | ||
--- a/c2me-fixes-worldgen-threading-issues/src/main/resources/c2me-fixes-worldgen-threading-issues.mixins.json | ||
+++ b/c2me-fixes-worldgen-threading-issues/src/main/resources/c2me-fixes-worldgen-threading-issues.mixins.json | ||
@@ -37,6 +37,7 @@ | ||
"threading.MixinWoodlandMansionGeneratorMansionParameters", | ||
"threading.math.MixinAffineTransformation", | ||
"threading.math.MixinDirectionTransformation", | ||
- "threading_detections.random_instances.MixinWorld" | ||
+ "threading_detections.random_instances.MixinWorld", | ||
+ "threading_detections.readonly_protection.MixinChunkRegion" | ||
] | ||
} |