From c42fffad3c4c19950107ce4b2d9497cf175f1413 Mon Sep 17 00:00:00 2001 From: Ap_Tx <3045929398@qq.com> Date: Sun, 4 Oct 2026 18:06:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20instantFall=E6=94=B9=E7=94=A8ModifyArg?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=94=B9scheduleTick=E7=9A=84delay=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getDelayAfterPlace的hook可能被子类覆盖,改用ModifyArg拦截onPlace/updateShape的scheduleTick调用更可靠。 --- .../mixin/legacy/FallingBlockMixin.java | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/mixin/legacy/FallingBlockMixin.java b/src/main/java/com/github/zly2006/carpetslsaddition/mixin/legacy/FallingBlockMixin.java index 40e138d..1bd88be 100644 --- a/src/main/java/com/github/zly2006/carpetslsaddition/mixin/legacy/FallingBlockMixin.java +++ b/src/main/java/com/github/zly2006/carpetslsaddition/mixin/legacy/FallingBlockMixin.java @@ -10,6 +10,7 @@ import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -19,16 +20,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; *

1.12:世界装饰时短暂开启 instantFall,使重力方块在被更新时【立即】转为下落实体, * 而不等待 2gt 的计划刻延迟。26.1.2 已移除该 flag。 * - *

实现: + *

实现方式(双保险): *

*/ @Mixin(FallingBlock.class) public abstract class FallingBlockMixin { - /** instantFall:把"放置后延迟"改为 0(最小延迟)。 */ + /** instantFall:把"放置后延迟"改为 0。 */ @Inject(method = "getDelayAfterPlace", at = @At("HEAD"), cancellable = true) private void legacyDelayAfterPlace(CallbackInfoReturnable cir) { if (SLSCarpetSettings.legacyExploitMode && SLSCarpetSettings.legacyInstantFall) { @@ -36,6 +38,36 @@ public abstract class FallingBlockMixin { } } + /** + * instantFall:拦截 onPlace / updateShape 里 scheduleTick 的 delay 参数,强制为 0。 + * 第 3 个参数(index=2)是延迟 tick 数。 + */ + @ModifyArg( + method = "onPlace", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;scheduleTick(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;I)V"), + index = 2 + ) + private int legacyScheduleDelayLevel(int delay) { + if (SLSCarpetSettings.legacyExploitMode && SLSCarpetSettings.legacyInstantFall) { + return 0; + } + return delay; + } + + @ModifyArg( + method = "updateShape", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/ScheduledTickAccess;scheduleTick(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;I)V"), + index = 2 + ) + private int legacyScheduleDelayAccess(int delay) { + if (SLSCarpetSettings.legacyExploitMode && SLSCarpetSettings.legacyInstantFall) { + return 0; + } + return delay; + } + /** instantFall:tick 入口标记(供其他机制判断窗口)。 */ @Inject(method = "tick", at = @At("HEAD")) private void legacyTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource rand, CallbackInfo ci) {