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

Remove dropitem from block!

Comments in 'Plugin Development' started by KHAV, Sep 23, 2016.

  1. KHAV
    Offline

    KHAV New Member

    Joined:
    Aug 7, 2016
    Posts:
    35
    Minecraft User:
    KHAV
    Hi

    How i can make when you break like diamond ore don't drop diamond?:)
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    BlockBreakEvent, check if it's the block and if it is, use BlockBreakEvent::setDrops() to change the drops.
    Primus likes this.
  3. Yeelze
    Offline

    Yeelze New Member

    Joined:
    Apr 2, 2016
    Posts:
    31
    Minecraft User:
    Yeelze
    PHP:
    use pocketmine\item\Item;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\event\block\BlockBreakEvent;

    public function 
    onBreak(BlockBreakEvent $event) {
        switch(
    $event->getItem()->getId()) {
            case 
    Block::YOUR_BLOCK:
                
    $event->setDrops([Item::get(0)]);
                break;
        }
    }
    Primus likes this.
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Why [Item::get(0)]? Just pass an empty array, there's no need for Air. Also, it is getBlock(), not getItem(), since you don't want to know the item that has been used to break the block.

    All in all: Please make sure your code works and is correct. (correct -> exactly what is needed. Not that it is running fine!)
    Though, I don't think it helps @KHAV to post the full code. You can post snippets, so he'd need to code something himself, but just giving him the full code will probably(most of the time) make him simply copy & paste it without really thinking about what he copied there.


    For reference of the above:
    https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/Player.php#L2274-L2282
    https://github.com/PocketMine/Pocke...pocketmine/event/block/BlockEvent.php#L41-L46
    https://github.com/PocketMine/Pocke...tmine/event/block/BlockBreakEvent.php#L72-L77

Share This Page

Advertisement