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

potions

Comments in 'Plugin Development' started by Creeperface, Sep 4, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    when player drink a potion or eat food it is same packet right?
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Look at source code :p
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    Potions are not implemented and i want to implement them for my server :p
    Taha_The_Hacker likes this.
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    GL & HF. And i think yes, because eating Puffer Fish gives a bad effect either the meat from zombies
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  6. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    it's inpossible, you need th texture pack that has the potions so it works.
    SeifValkierks likes this.
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    0.12.0 has potions
    SeifValkierks likes this.
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    i know. but i ment in 11.0
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    but i meant in 0.12.1 :p
    PEMapModder and SeifValkierks like this.
  10. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    this is pocketmine code but why it doesn´t work? players can´t drink potions
    PHP:
    switch($packet->event){
                        case 
    9//Eating
                            
    $items = [ //TODO: move this to item classes
                                
    Item::APPLE => 4,
                                
    Item::MUSHROOM_STEW => 10,
                                
    Item::BEETROOT_SOUP => 10,
                                
    Item::BREAD => 5,
                                
    Item::RAW_PORKCHOP => 3,
                                
    Item::COOKED_PORKCHOP => 8,
                                
    Item::RAW_BEEF => 3,
                                
    Item::STEAK => 8,
                                
    Item::COOKED_CHICKEN => 6,
                                
    Item::RAW_CHICKEN => 2,
                                
    Item::MELON_SLICE => 2,
                                
    Item::GOLDEN_APPLE => 10,
                                
    Item::PUMPKIN_PIE => 8,
                                
    Item::CARROT => 4,
                                
    Item::POTATO => 1,
                                
    Item::BAKED_POTATO => 6,
                                
    Item::COOKIE => 2,
                                
    Item::COOKED_FISH => [
                                    
    => 5,
                                    
    => 6
                                
    ],
                                
    Item::RAW_FISH => [
                                    
    => 2,
                                    
    => 2,
                                    
    => 1,
                                    
    => 1
                                
    ],
                                
    373 => [
                                    
    21 => 4,
                                    
    22 => 8
                                
    ],
                            ];
                            
    $slot $this->inventory->getItemInHand();
                            if(
    $this->getHealth() < $this->getMaxHealth() and isset($items[$slot->getId()])){
                                
    $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this$slot));
                                if(
    $ev->isCancelled()){
                                    
    $this->inventory->sendContents($this);
                                    break;
                                }

                                
    $pk = new EntityEventPacket();
                                
    $pk->eid $this->getId();
                                
    $pk->event EntityEventPacket::USE_ITEM;
                                
    $pk;
                                
    $this->dataPacket($pk);
                                
    Server::broadcastPacket($this->getViewers(), $pk);

                                
    $amount $items[$slot->getId()];
                                if(
    is_array($amount)){
                                    
    $amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
                                }
                                
    $ev = new EntityRegainHealthEvent($this$amountEntityRegainHealthEvent::CAUSE_EATING);
                                
    $this->heal($ev->getAmount(), $ev);

                                --
    $slot->count;
                                
    $this->inventory->setItemInHand($slot$this);
                                if(
    $slot->getId() === Item::MUSHROOM_STEW or $slot->getId() === Item::BEETROOT_SOUP){
                                    
    $this->inventory->addItem(Item::get(Item::BOWL01));
                                }elseif(
    $slot->getId() === Item::RAW_FISH and $slot->getDamage() === 3){ //Pufferfish
                                    
    $this->addEffect(Effect::getEffect(Effect::HUNGER)->setAmplifier(2)->setDuration(15 20));
                                    
    //$this->addEffect(Effect::getEffect(Effect::NAUSEA)->setAmplifier(1)->setDuration(15 * 20));
                                    
    $this->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(3)->setDuration(60 20));
                                }elseif(
    $slot->getId() === 373 and $slot->getDamage() === 31){ //potion strenght
                                    
    $this->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(1)->setDuration(180 20));
                                }
                                elseif(
    $slot->getId() === 373 and $slot->getDamage() === 14){ //potion speed
                                    
    $this->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(1)->setDuration(180 20));
                                }
                                elseif(
    $slot->getId() === 373 and $slot->getDamage() === 28){ //potion regeneration
                                    
    $this->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(1)->setDuration(45 20));
                                }
                            }
                            break;
                    }
                    break;
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I think you should just wait for PocketMine to implement it.
    FuryTacticz and SeifValkierks like this.
  12. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    so it is not same packet?
  13. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    no it works too :D
  14. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    2 likes and maybe i will be a Notable member :D
    and why potions in MCPE have different metadata than in PC version?
    Yoyo95220 and Taha_The_Hacker like this.
  15. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    enough likes? :p:p
    Creeperface and SeifValkierks like this.
  16. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    thx :p
    Yoyo95220 likes this.
  17. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    ..made her Notable..lol
    SeifValkierks likes this.
  18. SeifValkierks
    Offline

    SeifValkierks New Member

    Joined:
    Sep 4, 2015
    Posts:
    12
    Minecraft User:
    SeifVan
  19. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i think it should be "him" or "he"
  20. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You think xD

Share This Page

Advertisement