Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cancelling block break but not with BlockBreakEvent

Comments in 'Plugin Development' started by Jelly9912, Dec 22, 2015.

  1. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    How to cancel block break but not with BlockBreakEvent, for example, if you have some sword in hand, you can't break anything. What is the code for this?
  2. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    you must use blockBreakEvent and check the item in the player hand if is a sword then cancel the event
  3. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    PHP:
    //to get the item id i think you can use this
    $ev->getItem()->getID()
    $ev is the BlockBreakEvent
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Cancel PlayerInteractEvent (Guess), or set player's gamemode to adventure (2 or 3, I think) [100%]. Remember, they can't pvp in adventure.
    Vaivez66 likes this.
  5. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    But if playerInteractEvent is cancelled then i can't use TapToDo yea?
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    First of all, what do you mean by "not with BlockBreakEvent"? What's the reason behind that?
    Andrey Nazarchuk likes this.
  7. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    I think the player not being able to break any block with a sword in hand is done client side? Not sure abt this..
    PEMapModder likes this.
  8. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    For example, when you joined the arena in the skywars on the lifeboat server, you can't destroy the glass around you, the blocks are destroyed to some 90% and then renewed
  9. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    That because you are in adventure mode
    PEMapModder and Vaivez66 like this.
  10. Taki21
    Offline

    Taki21 New Member

    Joined:
    Sep 24, 2015
    Posts:
    11
    Minecraft User:
    Taki21
    For cancelling block break event you simply do this (PS. YOU MUST USE BLOCK BREAK EVENT :D)
    PHP:
    $event->setCancelled();
    :)
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    He is talking about the adventure mode unbreakability, I guess.
    iDirtPlayzMC and Vaivez66 like this.
  12. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    This will be working in only e.g. "spawn" area?
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    change their gamemode when they leave spawn.
    Jelly9912 likes this.
  14. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    Make an area of spawn set it in config, then cancel blockbreakevent when player is at that area
  15. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    example of iProtector
  16. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    What is the number of adventure gamemode?
  17. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    gamemode 2
  18. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    2
    Ever heard of Google?
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Actually, they can PvP in gamemode 2.
    Jelly9912 likes this.
  20. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    This isn't problem ;)
    Thanks for help guys

Share This Page

Advertisement