diff --git a/patches/main/0008-new-strict-detection-for-scheduled-tick-access.patch b/patches/main/0008-new-strict-detection-for-scheduled-tick-access.patch new file mode 100644 index 0000000..f70af31 --- /dev/null +++ b/patches/main/0008-new-strict-detection-for-scheduled-tick-access.patch @@ -0,0 +1,74 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ishland +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 wrapBlockScheduledTick(BlockPos pos, Operation> 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 wrapFluidScheduledTick(BlockPos pos, Operation> 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" + ] + }