-
Bug
-
Resolution: Unresolved
-
None
-
1.16.3, 1.16.4 Pre-release 2, 1.16.4 Release Candidate 1, 1.16.4, 20w46a, 20w51a, 21w03a, 1.16.5, 21w05b, 21w06a, 21w07a, 21w13a, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.20.4
-
None
-
Confirmed
-
Block states, Items
-
Normal
-
Platform
The bug
When you try to plant a seed at the same time as breaking an existing crop, the seed will drop out of your inventory instead of being planted. This is inconsistent with other blocks as normally they will just replace the broken block.
Code analysis
TriWonder81 - Yarn mappings, 1.18.2
The cause of this issue is that no cooldown is set between blocks being broken in survival, as it is in creative.
This causes an instantly breakable block to be immediately broken again if this is performed in the correct way on survival mode.
The fix for this would be adding something similar to the following line, adding cooldown if the block is instantly replaceable to ClientPlayerInteractionManager#attackBlock() when it is broken in order to preserve current instamining behaviour.
public boolean attackBlock(BlockPos pos, Direction direction) { ... this.sendSequencedPacket(this.client.world, sequence -> { boolean bl; boolean bl2 = bl = !lv.isAir(); if (bl && this.currentBreakingProgress == 0.0f) { lv.onBlockBreakStart(this.client.world, pos, this.client.player); } if (bl && lv.calcBlockBreakingDelta(this.client.player, this.client.player.world, pos) >= 1.0f) { // Add this check here: if (this.client.world.getBlockState(pos).getBlock().getHardness() == 0.0f) { this.blockBreakingCooldown = 5; } this.breakBlock(pos); } else { this.breakingBlock = true; this.currentBreakingPos = pos; this.selectedStack = this.client.player.getMainHandStack(); this.currentBreakingProgress = 0.0f; this.blockBreakingSoundCooldown = 0.0f; this.client.world.setBlockBreakingInfo(this.client.player.getId(), this.currentBreakingPos, (int)(this.currentBreakingProgress * 10.0f) - 1); } return new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence); }); ... }