mojira.dev
MC-142301

Eating the final slice of cake does not produce particles

The bug

Most instances of blocks being broken or deleted result in the block producing particles. However, this is not true for cake. Upon consuming the final slice of a cake block, no particles/sounds are emitted to signify the deletion of the cake block.

Code analysis

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

Linked issues

Attachments

Comments 14

well, not to be funny, but you would propaly not be so uncarefull when you eat so that you produce crums. if you on the other hand break it like it is a block, it will make sense to have it emitt partickels. Other or similar effects in the game that do not have an effect when being "used up" is cauldrons filled with water. if you drain the water out with a bucket, no particels appear.

Is it really not intentional? It is not like there are any particles when eating other slices in the first place

Can confirm in 20w51a.

Can confirm in 21w05b.

Can confirm in 21w06a.

4 more comments

Can confirm in 1.18.1.

Can confirm in 1.18.2.

Can confirm in 22w18a. Here's a code analysis of 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.CakeBlock.java

public class CakeBlock extends Block {
   ...
   protected static InteractionResult eat(LevelAccessor $la, BlockPos $bp, BlockState $bs, Player $p) {
      if (!$p.canEat(false)) {
         return InteractionResult.PASS;
      } else {
         $p.awardStat(Stats.EAT_CAKE_SLICE);
         $p.getFoodData().eat(2, 0.1F);
         int i = $bs.getValue(BITES);
         $la.gameEvent($p, GameEvent.EAT, $bp);
         if (i < 6) {
            $la.setBlock($bp, $bs.setValue(BITES, Integer.valueOf(i + 1)), 3);
         } else {
            $la.removeBlock($bp, false);
            $la.gameEvent($p, GameEvent.BLOCK_DESTROY, $bp);
         }

         return InteractionResult.SUCCESS;
      }
   }
   ...

If we look at the above class, we can see that the removeBlock() method is called when the final slice of a cake is eaten. This is evident through the following line of code:

$la.removeBlock($bp, false);

The problem here is that the removeBlock() method is simply designed to remove the desired block and not have it produce any sounds or particles upon being removed. Because of this, eating the last slice of cake will not produce any particles, therefore resulting in this issue occurring.

Can confirm in 1.19.

Can confirm in 1.19.2.

muzikbike

(Unassigned)

Confirmed

Particles

cake, general-breaking-zone, missing-particle

Minecraft 18w50a, Minecraft 19w02a, Minecraft 19w03a, Minecraft 19w03b, Minecraft 19w04a, ..., 1.19.3, 1.19.4, 1.20.1, 1.20.4, 1.21

Retrieved