Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sculk sensor range #1380

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32? interesting.

Dev note - the performance will be terrible above 16, but hay, its for experiments, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup it will be, I wanted to do some hitbox checks for more angles & some performance testing for higher numbers since it should be possible to reduce the lag by using poi to prevent chunks that don't contain sculk sensors from being loaded


}
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