diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 0ef12c344d..22c47e4a36 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -1102,4 +1102,13 @@ public String description() { ) public static boolean creativePlayersLoadChunks = true; + @Rule( + desc = "Customizable sculk sensor range", + options = {"8", "16", "32"}, + category = CREATIVE, + strict = false, + validate = PushLimitLimits.class + ) + public static int sculkSensorRange = 8; + } diff --git a/src/main/java/carpet/mixins/SculkSensorBlock_rangeMixin.java b/src/main/java/carpet/mixins/SculkSensorBlock_rangeMixin.java new file mode 100644 index 0000000000..3e0a20776f --- /dev/null +++ b/src/main/java/carpet/mixins/SculkSensorBlock_rangeMixin.java @@ -0,0 +1,30 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.world.level.block.SculkSensorBlock; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(SculkSensorBlock.class) +public class SculkSensorBlock_rangeMixin { + + @Shadow + @Final + private int listenerRange; + + + @Inject( + method = "getListenerRange()I", + at = @At("HEAD"), + cancellable = true + ) + public void getListenerRange(CallbackInfoReturnable cir) { + if (CarpetSettings.sculkSensorRange != this.listenerRange) { + cir.setReturnValue(CarpetSettings.sculkSensorRange); + } + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 77201504f2..c7239d9d22 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -194,7 +194,8 @@ "Level_updateSuppressionCrashFixMixin", "MinecraftServer_updateSuppressionCrashFixMixin", "ServerPlayer_updateSuppressionCrashFixMixin", - "ChunkMap_creativePlayersLoadChunksMixin" + "ChunkMap_creativePlayersLoadChunksMixin", + "SculkSensorBlock_rangeMixin" ], "client": [ "Timer_tickSpeedMixin",