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

How to spawn Arrow with nbt

Discussion in 'Development' started by armagadon159753, Aug 29, 2017.

  1. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
  2. Enes5519

    Enes5519 Spider Jockey

    Messages:
    28
    GitHub:
    Enes5519
    PHP:
    $nbt = new CompoundTag("", [
                                        
    "Pos"      => new ListTag("Pos", [
                                            new 
    DoubleTag(""$x),
                                            new 
    DoubleTag(""$y),
                                            new 
    DoubleTag(""$z),
                                        ]),
                                        
    "Motion"   => new ListTag("Motion", [
                                            new 
    DoubleTag("", -sin($yaw 180 M_PI) * cos($pitch 180 M_PI)),
                                            new 
    DoubleTag("", -sin($pitch 180 M_PI)),
                                            new 
    DoubleTag(""cos($yaw 180 M_PI) * cos($pitch 180 M_PI)),
                                        ]),
                                        
    "Rotation" => new ListTag("Rotation", [
                                            new 
    FloatTag(""$yaw),
                                            new 
    FloatTag(""$pitch),
                                        ])
                                    ]);

    $arrow Entity::createEntity("Arrow"$level$nbt);

    $arrow->spawnToAll();

    // pmmp
     
    armagadon159753 likes this.
  3. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753

    It does not really work and your variables are not set
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    How sure are you that your code is being executed?
     
  5. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    It's bizarre explained but the arrow does not spawn properly
     
  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.