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

DATA_FLAG's on Entities

Discussion in 'Plugin Help' started by JUSTaMod, Jul 19, 2018.

  1. JUSTaMod

    JUSTaMod Spider Jockey

    Messages:
    38
    GitHub:
    justamod
    I was wondering what the correct syntax was for using specific data flags for entities.

    Lets say... for Slapper. I've added in the ender dragon as a spawnable entity. Sure, that works. The exception to that being- it blows up immediately.

    My first thought was, "It's spawning with no health! lets flag it to have more within slapper."

    However looking at my slapper entity code here (which follows how it is in the rest of the slapper entities that use flags) -

    class SlapperEnderDragon extends SlapperEntity {

    const TYPE_ID = 53;
    const HEIGHT = 4;

    public function prepareMetadata(): void {
    $this->setDataFlag(self:: DATA_FLAGS, self:: DATA_HEALTH, true);
    parent:: PrepareMetadata();
    }
    }

    the third argument of setDataFlag must be boolean, not an integer. Which solves nothing- except for making it float up while exploding.

    Any ideas? I'm assuming i'm doing it horribly wrong. Maybe I'm even on the wrong train of thought.
    As per the usual, thank you, in advance.


    EDIT- added spaces for the sake of the post after SELF:: and parent:: (damn smiley faces.)
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I may be mistaken, but I believe the purpose of these flags is that they can only be true or false, like a real flag. You can only raise the flag to cause one behavior, or keep it lowered to do something else. Most Slapper Entities are different from Ender Dragons, so it makes sense it would be more difficult to implement. I'm not certain, but I believe this code from SlapperHuman may be helpful. While the context is totally different, it may give you an idea of how to approach your problem.

    PS: Use
    Code:
    [PHP] and [/PHP]
    tags around your code to remove problems with emoticons in code. Plus, it makes it easier to read.
     
    HimbeersaftLP likes this.
  3. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    Health should not be setdirectly via flag.. also its a property and not a flag.

    The enderdragon despawns for another reason, i'd concider it a client bug. You would need to send an event packet stopping the death animation, see the function "stopDeathAnimation" in Entity.php.. or it was Living.php, i am not entirely sure
     
    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.