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

BlockBreakEvent getting position

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

  1. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    Can somone give me a code for getting position of block on BlockBreakEvent? :D
    Thanks in advance
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    PHP:
    $event->getBlock()->getX();
    $event->getBlock()->getY();
    $event->getBlock()->getZ();
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $event->getBlock();
    is a Position itself.
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    yes, it extends Position.
  5. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    I want get position and check "if($X == 266, (...)){
    do something;
    } and thats all xd
  6. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    PHP:
        public function blockBreak(BlockBreakEvent $event){

            
    $block $event->getBlock();
            
    $player $event->getPlayer();
            
    $X $block->getX();
            
    $Y $block->getY();
            
    $Z $block->getZ();
           
            if(
    $X == 266 && $Y == 68 && $Z == 196){
              
    $event->setCancelled();
              
    $player->getLevel()->dropItem($block, new Item(1701));
           
            }
    What is wrong?
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No relevance at all... This shows that you don't even know what you are writing in your code.
    hoyinm14mc and CraftYourBukkit like this.
  8. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912

Share This Page

Advertisement