1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Please help me

Discussion in 'Help' started by Ngao, Apr 11, 2017.

  1. Ngao

    Ngao Silverfish

    Messages:
    18
    public function onBreak(BlockBreakEvent $event) {
    $island = $this->plugin->getIslandManager()->getOnlineIsland($event->getPlayer()->getLevel()->getName());
    if($island instanceof Island) {
    if(!$event->getPlayer()->isOp() and !in_array(strtolower($event->getPlayer()->getName()), $island->getAllMembers())) {
    $event->getPlayer()->sendPopup(TextFormat::RED . "You must be part of this island to break here!");
    $event->setCancelled();
    }
    else {
    if($event->getBlock()->getId() == Block::COBBLESTONE) {

    - Please help me write code that when players block the block will drop random item ...
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Pleeeease use code blocks...
    Please use:
    [PHP]Put your php code here[/PHP]

    or for normal code or files that aren't php:

    [CODE]Put normal code or file content (e.g. configs) here[/CODE]
     
  3. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    PHP:
    if($event->getBlock()->getId() === 14) {
        
    $drops = array();
        
    $drops[] = new Item(<blockID>, 0, <amount>);
        
    $event->setDrops($drops);
    }
     
  4. Ngao

    Ngao Silverfish

    Messages:
    18
    thank :))
     
  5. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    If you want it to drop a random block/item:
    PHP:
    if($event->getBlock()->getId() === 14) {
        
    $random mt_rand(1,435);
        
    $drops = array();
        
    $drops[] = new Item($random0, <amount>);
        
    $event->setDrops($drops);
    }
     
  6. Ngao

    Ngao Silverfish

    Messages:
    18
    At my code for SkyBlock Plugin, Well
    For example: Can lava + water create random blocks?
     
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    This is the wrong section for development questions.
    To answer your question however, yes, lava and water can create set blocks.
     
  8. Ngao

    Ngao Silverfish

    Messages:
    18
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.