mojira.dev
MC-214622

Sculk sensors do not detect daylight detector mode switching

I'd strongly recommend also adding a sound (or empty sound event at the very least) for this, since many related actions (e.g. changing a comparator's mode) have sounds.

This action would without a doubt be considered a "block change", and as such should create a vibration of some sort.

How to reproduce

  • Place down a daylight detector and a sculk sensor nearby

  • Change the mode of the daylight detector by right-clicking on it

  • Take note as to whether or not a vibration is created and/or if the sculk sensor is activated upon switching the daylight detector's mode

Expected Behavior

A vibration would be produced upon switching daylight detector modes, which the sculk sensor would detect.

Observed Behavior

No such vibration is produced, and the sculk sensor is not activated at all.

Code analysis

Code analysis by @unknown can be found in this comment.

Attachments

Comments 16

Can confirm in 21w06a.

Can confirm in 21w07a.

Can confirm in 21w08b.

6 more comments

Can confirm in 1.17.1.

Can confirm this behavior in 21w43a. Here are some extra details regarding this problem.

The Bug:

Sculk sensors are not activated upon switching between daylight detector modes.

Steps to Reproduce:

  • Place down a daylight detector and a sculk sensor nearby.

  • Change the mode of the daylight detector by right-clicking on it.

  • Take note as to whether or not sculk sensors are activated upon switching between daylight detector modes.

Observed Behavior:

Sculk sensors are not activated upon switching between daylight detector modes.

Expected Behavior:

Sculk sensors would be activated upon switching between daylight detector modes.

Can confirm in 1.18.1.

Can confirm in 1.18.2.

Can confirm in 22w18a. Here's a code analysis regarding this issue.

Code Analysis:

The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.

net.minecraft.world.level.block.DaylightDetectorBlock.java

public class DaylightDetectorBlock extends BaseEntityBlock {
   ...
   public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) {
      if ($p.mayBuild()) {
         if ($l.isClientSide) {
            return InteractionResult.SUCCESS;
         } else {
            BlockState blockstate = $bs.cycle(INVERTED);
            $l.setBlock($bp, blockstate, 4);
            updateSignalStrength(blockstate, $l, $bp);
            return InteractionResult.CONSUME;
         ...

If we look at the above class, we can see that switching the "inverted" mode on daylight detectors simply isn't registered as a game event as the gameEvent() method is never called, thus not detecting this action as a vibration.

Potential Fix:

Simply calling the gameEvent() method where appropriate within this piece of code should resolve this problem. The "BLOCK_CHANGE" game event tag would be expected to be used here as the block states of daylight detectors are changed. The following line of code could be used in order to fix this:

$LEVEL.gameEvent($PLAYER, GameEvent.BLOCK_CHANGE, $BLOCKPOS);

muzikbike

kingbdogz

Confirmed

Normal

Game Events

sculk_sensor

21w05b, 21w06a, 21w07a, 21w08b, 21w11a, ..., 21w43a, 1.18.1, 1.18.2, 22w18a, 1.19 Pre-release 1

1.19 Pre-release 3

Retrieved