setDrops doesn't seem to work

Discussion in 'Development' started by 8675309, Oct 12, 2019.

  1. 8675309

    8675309 Spider

    Messages:
    6
    I don't get it, this should work right? No error, just a single drop in-game. Has something changed recently?


    PHP:
    public function onBlockBreak(BlockBreakEvent $event) : void {
        ...
        
    var_dump($drops);
        
    $event->setDrops($drops);
    }

    Code:
    array(1) {
      [0]=>
      object(pocketmine\item\ItemBlock)#18620 (7) {
        ["blockId":protected]=>
        int(17)
        ["id":protected]=>
        int(17)
        ["meta":protected]=>
        int(0)
        ["tags":"pocketmine\item\Item":private]=>
        string(0) ""
        ["cachedNBT":"pocketmine\item\Item":private]=>
        NULL
        ["count"]=>
        int(4)
        ["name":protected]=>
        string(8) "Oak Wood"
      }
    }
     
  2. Mr174

    Mr174 Baby Zombie

    Messages:
    110
    GitHub:
    Mr174
    Are you trying to make it where drops automatically go into a player's inventory?
     
  3. 8675309

    8675309 Spider

    Messages:
    6
    nope, I want there to be four drops on the ground. I assume from your question then I need to have four different drops in the drop array?
     
  4. Mr174

    Mr174 Baby Zombie

    Messages:
    110
    GitHub:
    Mr174
    Explain more
     
  5. 8675309

    8675309 Spider

    Messages:
    6
    Break one Oak log, 4 Oak logs to pickup

    it really is that simple
     
  6. Mr174

    Mr174 Baby Zombie

    Messages:
    110
    GitHub:
    Mr174
    What you're doing in your code is just calling the drop nothing else...
     
  7. 8675309

    8675309 Spider

    Messages:
    6
    No, what I am doing is setting the Item count for the drop'd Item. The Item still drops, but it drops a count of 1 and I want more than 1

    What more code does one need to drop multiple items from one Item drop other than set the drop count? Either setDrops(Item[]) sets the drop count per Item or it doesn't and I need to add individual Item's to the array. That's fine, but I assumed and Item drop with a count greater than 1 would drop more than one item.
     
  8. Mr174

    Mr174 Baby Zombie

    Messages:
    110
    GitHub:
    Mr174
    Lets see the rest of your code
     
  9. 8675309

    8675309 Spider

    Messages:
    6
    There is nothing else to see. BlockBreakEvent->setDrops($item[]) does it drop based on amount of items in the array or item->count for item? The contents of the array is in the first post of this thread.
     
  10. Mr174

    Mr174 Baby Zombie

    Messages:
    110
    GitHub:
    Mr174
    NGL you are making no sense.
    All that code does is tell you what has been broken it doesn't multiply / add the amount of drops
    The code does nothing that you are showing besides that
     
  11. wolfdale

    wolfdale Zombie

    Messages:
    369
    Well since you only shown some code and the code shows no problems, the error is likely somewhere else. Is this the only plugin on the server? No code=debug it yourself
     
  12. 8675309

    8675309 Spider

    Messages:
    6
    only plugin EDIT: besides devtools
    https://github.com/jasin/mcMMO/tree/dev
     
    Last edited: Oct 13, 2019

Share This Page

  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.