How can I disable block breakage? (Like bedrock)

Discussion in 'Spigot Plugin Development' started by SledgeR6, Jan 13, 2019.

  1. How can I disable block breakage?

    Thank you all.
  2. You can listen to BlockBreakEvent and check if the broken Material is Bedrock, and cancel the event if that's the case.
  3. you can use protocollib lib with blockdiggingevent, you can check my plugin called SoHard which is using protocollib :)
  4. How do you expect bedrock to be broken? It probably depends on that.
  5. I do not want the bedrock broken.
  6. I'm rephrasing what @Escad said: How can bedrock be broken? There are different ways to prevent this, but they depend on what is breaking the bedrock thus you need to know what could break bedrock in order to prevent it from happening.

    If it is done by players, you can use my solution. Otherwise you will have to find an appropriate solution yourself or describe what will destroy bedrock: Some explosion, mobs, Chuck Norris,... and we will try to help you.
    • Like Like x 1
  7. Unless it's Chuck Norris. Then he's out of luck ;)
    • Funny Funny x 2
  8. Do you want the same behaviour like interacting in survival with bedrock? Like Gamemode Adventure where you cannot break any block?
  9. Oh, OP's question clicks now.
    You'd probably use the BlockBreakEvent and cancel it, like vallas suggested at first. If you don't even want it to get to that point, you might be able to cancel the PlayerInteractEvent if the action is Action.LEFT_CLICK_BLOCK. You should ignore the event if it's cancelled via the EventHandler annotation, though. There's also no guarantee that other plugins won't interfere with the cancelled event.

    edit:// you could also just put your players in adventure mode if you don't want them breaking or interacting with anything at all.
    #9 Escad, Jan 13, 2019
    Last edited: Jan 13, 2019
  10. Yes
    • Optimistic Optimistic x 1
  11. Then this is probably your solution:
    I'm not being lazy!!
    • Informative Informative x 1
  12. no its not a good solution because :)
    afted click to air and dont release, when you change your directiom where is looking a block th event does not fire, so my plugin has this bug :)
  13. 2008Choco

    Junior Mod

    Would actually instead recommend BlockDamageEvent. To my knowledge, this is called when a player first damages the block. It may have subsequent calls for every crack in the block, though I may be wrong. Never used it, personally.
    • Informative Informative x 2
    • Like Like x 1
    • Agree Agree x 1
  14. Thank you for correcting me. I'd have to do some testing then but I see @2008Choco has given a solution already. Good to know if I ever need this.

Share This Page