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
Is it really not intentional? It is not like there are any particles when eating other slices in the first place
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.
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.