mojira.dev
MC-209701

Sculk sensors are not activated upon placing food onto campfires

The Bug:

Sculk sensors are not activated upon placing food onto campfires.

Steps to Reproduce:

  • Place down a campfire.

  • Place down a sculk sensor nearby and place some food onto the campfire.

  • Take note as to whether or not sculk sensors are activated upon placing food onto campfires.

Observed Behavior:

Sculk sensors are not activated upon placing food onto campfires.

Expected Behavior:

Sculk sensors would be activated upon placing food onto campfires.

Code Analysis:

Code analysis by @unknown can be found below.

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

net.minecraft.world.level.block.CampfireBlock.java

public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedBlock {
   ...
   public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) {
      BlockEntity blockentity = $l.getBlockEntity($bp);
      if (blockentity instanceof CampfireBlockEntity) {
         CampfireBlockEntity campfireblockentity = (CampfireBlockEntity)blockentity;
         ItemStack itemstack = $p.getItemInHand($ih);
         Optional<CampfireCookingRecipe> optional = campfireblockentity.getCookableRecipe(itemstack);
         if (optional.isPresent()) {
            if (!$l.isClientSide && campfireblockentity.placeFood($p.getAbilities().instabuild ? itemstack.copy() : itemstack, optional.get().getCookingTime())) {
               $p.awardStat(Stats.INTERACT_WITH_CAMPFIRE);
               return InteractionResult.SUCCESS;
            }
            ...

If we look at the above class, we can see that placing food onto campfires 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 campfires are visually changed when food is placed onto them. The following line of code could be used in order to fix this:

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

Attachments

Comments 1

Can confirm. Affects both regular and soul campfires.

Avoma

kingbdogz

Confirmed

Normal

Game Events

sculk_sensor

20w51a, 21w03a, 21w05a, 21w05b, 21w06a, ..., 1.18.2, 22w14a, 22w17a, 22w18a, 1.19 Pre-release 1

1.19 Pre-release 2

Retrieved