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

How to show a plash potion effect on entity hit?

Discussion in 'Development' started by rektpixel, Sep 29, 2017.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    Hello, I was wondering if it's possible to display the healing splash potion effect when a player is hit to make it look like blood and how would this be done? I have added an image below to show you what effect I'm talking about.
    thanks
    edit: although the harming splash probably looks better to use :3
     

    Attached Files:

    Last edited: Sep 29, 2017
  2. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    Well, what have you tried? You need to show us your previous attempts.
     
  3. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    I haven't had any previous attempts because I have no idea if it's possible
     
  4. AshBull

    AshBull Spider Jockey

    Messages:
    31
    Then this is the wrong section.
    However, you can re-implement the SpellParticle and set whatever color you want
    PHP:
    <?php

    namespace your\namespace;

    use 
    pocketmine\level\particle\GenericParticle;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\network\mcpe\protocol\LevelEventPacket;

    class 
    SpellParticle extends GenericParticle {

       public function 
    __construct(Vector3 $pos$r 0$g 0$b 0$a 255) {
          
    parent::__construct($posLevelEventPacket::EVENT_PARTICLE_SPLASH, (($a 0xff) << 24) | (($r 0xff) << 16) | (($g 0xff) << 8) | ($b 0xff));
       }

       public function 
    encode() {
          
    $pk = new LevelEventPacket();
          
    $pk->evid LevelEventPacket::EVENT_PARTICLE_SPLASH;
          
    $pk->position $this->asVector3();
          
    $pk->data $this->data;
          return 
    $pk;
       }
    }
    PHP:
    $red 230;
    $green 0;
    $blue 0;
    $level->addParticle(new SpellParticle($location$red$green$blue));

    Or you could just send a LevelEventPacket and not create a new class for SpellParticle
     
    jasonwynn10 likes this.
  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.