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

Ore from stone plugin

Comments in 'Plugin Development' started by Juqxi, Sep 22, 2015.

Thread Status:
Not open for further replies.
  1. Jelly9912
    Offline

    Jelly9912 Active Member

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

    Code:
    PocketMine-MP Crash Dump Thu Oct 8 14:21:29 UTC 2015
    
    Error: syntax error, unexpected ']'
    File: /StoneDrop/src/StoneDrop/StoneDrop
    Line: 20
    Type: E_PARSE
    
    THIS CRASH WAS CAUSED BY A PLUGIN
    
    Code:
    [11]
    [12] public function onEnable() {
    [13]         $this->getLogger()->info("StoneDrop is enabled!");
    [14]         $this->getServer()->getPluginManager ()->registerEvents ( $this, $this );
    [15]   
    [16]         $ores = [Item::GOLD_ORE, Item::IRON_ORE, Item::DIAMOND_ORE, Item::COAL_ORE, Item::REDSTONE_ORE];
    [17]         }
    [18]
    [19]         public function onBlockBreak(BlockBreakEvent $e){
    [20]     if($e->getBlock()->getId() === Block::STONE) $e->setDrops([Item::get($ores[mt_rand(0, count($ores) - 1], 0, mt_rand(0, 5)]);
    [21]     }
    [22]    }
    [23] ?>
    [24]
    [25]
    [26]
    [27]
    [28]
    [29]
    [30]
    
    Backtrace:
    #0 (): pocketmine\Server->crashDump(boolean)
    
    PocketMine-MP version: 1.6dev #35 [Protocol 34; API 1.13.0]
    Git commit: 0000000000000000000000000000000000000000
    uname -a: Linux localhost 3.4.0-4760392 #1 SMP PREEMPT Fri May 15 17:47:47 KST 2015 armv7l
    PHP Version: 5.6.2
    Zend version: 2.6.0
    OS : Linux, android

    @PEMapModder Edit: now i have this
    Code:
    public function onEnable() {
            $this->getLogger()->info("StoneDrop is enabled!");
            $this->getServer()->getPluginManager ()->registerEvents ( $this, $this );
        
            $ores = [Item::GOLD_ORE, Item::IRON_ORE, Item::DIAMOND_ORE, Item::COAL_ORE, Item::REDSTONE_ORE];
            }
    
            public function onBlockBreak(BlockBreakEvent $e){
        if($e->getBlock()->getId() === Block::STONE) $e->setDrops([Item::get($ores[mt_rand(0, 5)])]);
        }
    and still drop from stone is cobble
    Last edited: Oct 8, 2015
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $ores is a local variable, which can only be used inside that function. You should define it as a field, it as a variable in the break function.
  3. Jelly9912
    Offline

    Jelly9912 Active Member

    Joined:
    Aug 8, 2015
    Posts:
    118
    Minecraft User:
    Jelly9912
    You mean ?
    Code:
      $ores = [Item::GOLD_ORE, Item::IRON_ORE, Item::DIAMOND_ORE, Item::COAL_ORE, Item::REDSTONE_ORE];
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yep
  5. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Can you stop picking up flames? That reply was from about a month ago. BTW he made 4 alt accounts to like himself.
    Off-topic: Approximately how many likes/posts did you have when you received notable status?
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    @Kvetinac97 did first.

    I forgot. That was so long ago.
    Legoboy0215 likes this.
  7. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    I know that @Kvetinac97 sparked it. But it's been awhile, and @Legoboy0215 wants to continue it. And yes, it was quite awhile back.
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    That's why you don't read posts too early...
    I forgot to check the time.
Thread Status:
Not open for further replies.

Share This Page

Advertisement