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

Is it possible to detect an interaction with FloatingTextParticle

Comments in 'Plugin Development' started by Tim // robske Büba, Mar 8, 2016.

  1. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Or do i have to spawn an invisible tile behind it to detect it?
    (I do have direct access to the FTP object and to its coordinates)
    And if so, how to spawn an invisible sign/tile?
    Skullex likes this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Define "intrraction"? Clicking? Collision? Staring? Or what?
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    No, FTPs cant be clicked thats why you need to do it with a block, but I am recommending you to do it with the PlayerInteract method, check on the event not the block, check the positon and yaw of the player, as example when the player's x is less than the FTPs x and his z is less than FTPs z then his Yaw needs to be between 0 and 90.
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Clicking
    And @MyNameIsTriXz thats much too complicated
    If i could spawn an invisble sign, it would be perfect!
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    FloatingTextParticle is an entity with a nametag. From the very beginning, you can only click (some) entities, not the nametag.
    Why don't you just detect if the player bounding box collides with the nametag?
  6. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Would spawning an invisible falling sand block work for you? If you just want it to run commands when you tap it you can make a Slapper falling sand entity then set its blockId to 0 using /slapper edit <id> blockid 0
    Tim // robske Büba likes this.
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Spawn an NBT entity, like jojoe77777 said, I am recommending you to use a falling sand block, and then just dont do $entity->spawnToAll(); , then you have an invisible entity
  8. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Ok, I will copy some of your code in my ServerCore... Am I allowed to do that (OffTopic: Oh no i'm starting to make classes, i hate me)
  9. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    What do you mean by "BoundingBox" can an bounding box of the hand calculated?
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. I meant "walking into". That is, if the player's body bounding box intersects with your text's bounding box.
    As for the size of the bounding box, you have to calculate it yourself.
  11. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Sure.
    Please don't post an answer until you have tested it. If you don't spawn the entity to the client, they won't know that it exists, so they can't interact with it.
  12. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I am almost finished, I gonna release an SUPER-advanced FTP plugin soon
    (No level issues, clickable FTPs)
    Skullex likes this.
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    So what's your theory about clicking FTP? A real FTP cannot be clicked.
  14. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Spawning an FallingSand block in it, detect clicking on it
  15. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Code:
    PHP:
    <?php
    //THIS CLASS IS ALMOST COMPLETLY TAKEN FROM SLAPPER!
    namespace robske_110\ServerCore;
    use 
    pocketmine\network\protocol\AddEntityPacket;
    use 
    pocketmine\network\Network;
    use 
    pocketmine\Player;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\nbt\tag\Byte;
    use 
    pocketmine\nbt\tag\Compound;
    use 
    pocketmine\nbt\tag\Double;
    use 
    pocketmine\nbt\tag\Enum;
    use 
    pocketmine\nbt\tag\Float;
    use 
    pocketmine\nbt\tag\Int;
    use 
    pocketmine\nbt\tag\Short;
    use 
    pocketmine\nbt\tag\String;
    class 
    SlapperFallingSand extends Entity implements ServerCoreEntity
    {
        const 
    NETWORK_ID 66;
        public function 
    getName()
        {
            return 
    $this->getDataProperty(2);
        }
        public function 
    spawnTo(Player $player)
        {
            
    $pk = new AddEntityPacket();
            
    $pk->eid $this->getId();
            
    $pk->type self::NETWORK_ID;
            
    $pk->$this->x;
            
    $pk->$this->y;
            
    $pk->$this->z;
            
    $pk->yaw $this->yaw;
            
    $pk->pitch $this->pitch;
            
    $pk->metadata = [
                
    => [4"WTF"],
                
    => [0$this->getDataProperty(3)],
                
    15 => [01]
            ];
            if (isset(
    $this->namedtag->BlockID)) {
                
    $pk->metadata[20] = [2$this->namedtag->BlockID->getValue()];
            } else {
                
    $pk->metadata[20] = [21];
            }
            
    $player->dataPacket($pk);
            
    parent::spawnTo($player);
        }
    }
    interface 
    ServerCoreEntity{
    }
    class 
    FallingSand extends Main
    {
        protected 
    $Entity;
        protected 
    $AssignedFTPuniqueID;
        public function 
    __construct($AssignedFTPuniqueID$level$coordX$coordY$coordZ)
        {
            
    $nbt $this->makeNBT(00$coordX$coordY$coordZ$AssignedFTPuniqueID);
            
    $slapperEntity Entity::createEntity("SlapperFallingSand"$this->getServer()->getLevelByName($level)->getChunk($coordX >> 4$coordZ >> 4), $nbt);
            
    $slapperEntity->spawnToAll();
            
    $this->Entity $slapperEntity;
            
    $this->AssignedFTPuniqueID $AssignedFTPuniqueID;
        }

        public function 
    kill(){
            
    $this->Entity->kill();
        }

        private function 
    makeNBT($yaw$pitch$x$y$z$AssignedFTPuniqueID)
        {
            
    $nbt = new Compound;
            
    $nbt->Pos = new Enum("Pos", [
                new 
    Double(""$x),
                new 
    Double(""$y),
                new 
    Double(""$z)
            ]);
            
    $nbt->Rotation = new Enum("Rotation", [
                new 
    Float(""$yaw),
                new 
    Float(""$pitch)
            ]);
            
    $nbt->Health = new Short("Health"1);
            
    $nbt->Invulnerable = new Byte("Invulnerable"1);
            
    $nbt->AssignedFTP = new Int("AssignedFTP"$AssignedFTPuniqueID);
            
    $nbt->RealServerCoreEnt = new String("RealServerCoreEnt""RealyAnServerCoreEnt");
            
    $nbt->BlockID = new Int("BlockID"0); #FallingSand Block ID
            
    $nbt->CustomNameVisible = new Byte("CustomNameVisible"0);
            return 
    $nbt;
        }
    }
    What I've done so far
    Skullex likes this.
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use constant references rather than the constant values. In this way, even if the value changes in MCPE's side, you don't ohave to update the plugin.
  17. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Tell that @jojoe77777 he is the owner of the SlapperFallingSand class, however i will update it for me
  18. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Small update: I'm still working on this

Share This Page

Advertisement