Skip to content

Commit

Permalink
Sculk sensor range (#1389)
Browse files Browse the repository at this point in the history
* New Rule: `sculkSensorRange`
  • Loading branch information
FxMorin authored Apr 3, 2022
1 parent 330fd6f commit 5e9b391
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/carpet/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
30 changes: 30 additions & 0 deletions src/main/java/carpet/mixins/SculkSensorBlock_rangeMixin.java
Original file line number Diff line number Diff line change
@@ -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<Integer> cir) {
if (CarpetSettings.sculkSensorRange != this.listenerRange) {
cir.setReturnValue(CarpetSettings.sculkSensorRange);
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/carpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@
"Level_updateSuppressionCrashFixMixin",
"MinecraftServer_updateSuppressionCrashFixMixin",
"ServerPlayer_updateSuppressionCrashFixMixin",
"ChunkMap_creativePlayersLoadChunksMixin"
"ChunkMap_creativePlayersLoadChunksMixin",
"SculkSensorBlock_rangeMixin"
],
"client": [
"Timer_tickSpeedMixin",
Expand Down

0 comments on commit 5e9b391

Please sign in to comment.