1.17.1 Reset the block breaking stage if block changes?

Discussion in 'Spigot Plugin Development' started by superblaze27, Oct 17, 2021.

  1. If a player is breaking a block, the block state is updated with block breaking animations. How can I make this so it resets the animations and starts breaking the new block from animation 0 if the block they are looking at changes?

    Also, let’s say there’s stone on the ground and I have a block damage event handler. When the player holds down their mine button, it checks if the block is stone, and if it is stone, it changes the block to cobblestone. Then, if the player is trying to mine cobblestone, it changes the block to bedrock. The only issue is that the player has to move their crosshair away from the cobblestone, and back to register the new block damage effect and then set the cobblestone to bedrock. How can I make this instant so that the player doesn’t have to look away and then back at the target block?
    • Creative Creative x 1
  2. Have you tried using the PlayerInteractEvent to change the block when a player left clicks it? Not sure if that resets the animation or not.

    If that doesn't work on its own, just send this packet when you change the block type.
  3. Yes, packets are the way. Send a new packet when you update the block. You could implement it simply by creating and calling a custom event when you update the block. Then create a listener for sending the packet to the player. You could hard code it, but I feel this way provides more flexibility.