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

[Need HELP] How to create a entity when I know the v3?

Comments in 'Plugin Development' started by xiaoq, May 3, 2015.

  1. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    I want to create a entity (PrimedTNT) with v3....o_O
  2. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    981
    Plugins:
    9
    I'm trying to learn how to add entities into levels, so here is what I think it is:
    PHP:
    $this->getServer()->getLevel()->addEntity(new PrimedTNT());
  3. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    well... ->_<-
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Entity::createEntity()
  5. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    I know.. But ... 就是createEntity("PrimedTNT"这里写什么);
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    /** @var Vector3 $v3 */
    /** @var Level $level */
    $nbt = new Compound("", [
      
    "Pos" => new Enum("Pos", [
        new 
    Double(""$v3->x),
        
    // same with y and z
      
    ]),
      
    "Motion" => new Enum("Motion", [
        new 
    Double(""0.0),
        new 
    Double(""0.2),
        new 
    Double(""0.0)
      ]),
      
    "Rotation" => new Enum("Rotation", [
        new 
    Float(""0),
        new 
    Float(""0)
      ]),
      
    "Fuse" => new Byte("Fuse"80)
    ]);
    $ent Entity::createEntity(new PrimedTNT($level->getChunk($v3->>> 4$v3->>> 4), $nbt)));
    $ent->spawnToAll();
    HotFireyDeath likes this.
  7. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    981
    Plugins:
    9
    I don't really get it still... :(

Share This Page

Advertisement