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

Spawn item entity and check when it touches ground or another entity.

Comments in 'Plugin Development' started by Flabe, Jan 21, 2016.

  1. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Hello dear friends))) , I have two problems
    1:I tried to spawn item Entity using this code , but it not works;
    2:I want to check when Item entity from this code touches ground or another entity(like player);
    Is this possible?
    Thx for your answers))
    PHP:
    $speed 0.8;
            
    $pos $player->getPosition();
            
    $dir $player->getDirectionVector();
            
    $frontPos $player->add($player->getDirectionVector()->multiply(1));
            
    $dir->$dir->$speed;
            
    $dir->$dir->$speed;
            
    $dir->$dir->$speed;
            
    $nbt =
                new 
    Compound("",
                             [
    "Pos" => new Enum("Pos",
                                [new 
    Double(""$frontPos->x),
                                    new 
    Double(""$frontPos->y+1),
                                    new 
    Double(""$frontPos->z)]),
                                
    "Motion" => new Enum("Motion",
                                [new 
    Double("",$dir->x),
                                    new 
    Double("",$dir->y),
                                    new 
    Double("",$dir->z)]),
                              
    "Rotation" => new Enum("Rotation",
                                [new 
    Float(""0),
                                    new 
    Float(""0)])]);
            
    Entity::createEntity(Item(1), $pos->getLevel()->getChunk($pos->>> 4$pos->>> 4),$nbt)->spawnTo($playrs);
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    What is Item(1)? Learn PHP.
  3. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    i know php -_- i just tried to spawn Item ENTITY not item packet or something else!
  4. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    If you don't have the answer don't type "Learn php" please
  5. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    On collide with entity, run this is a task etc.
    PHP:
    foreach($itemEntity->getLevel()->getNearbyEntities($itemEntity->boundingBox->grow(0.50.50.5), $itemEntity) as $e){
               
    //$e is the entity it collided with
            
    }
    If on ground
    PHP:
    $onGround count($itemEntity->getLevel()->getCollisionBlocks($itemEntity->boundingBox->grow(0.50.50.5)>offset(0, -0.10))) > 0;
    PHP:
    Entity::createEntity("Item"$p->chunk,$nbt)->spawnToAll();
    Last edited: Jan 21, 2016
  6. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    thanks but can you correct my code so i can spawn item entity
  7. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    You should be able to figure out where it goes if you know php... JUST SAYING
  8. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    and another question: how do i match Item entity that i spawned as $itemEntity???
  9. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    i understand where it goes i just can't spawn item entity something wrong with Item
  10. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    here is the problem part of the code
    PHP:
    Entity::createEntity(Item(1), $pos->getLevel()->getChunk($pos->>> 4$pos->>> 4),$nbt)->spawnTo($playrs);
  11. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
  12. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    PHP:
    Entity::createEntity("Item"$player->chunk,$nbt)->spawnToAll();
    Can you put all you want to say in one post? You are spamming the thread
  13. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    It isnt Item(1), what does Item(1) mean? It should be Item::get(1,0,1)

    You also misspelled players.
  14. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    http://forums.pocketmine.net/threads/spawn-a-snowball-as-projectile.12650/#post-127519
    Obviously, something is VERY weird, isn't it? The variable names, and the order they are defined is EXACTLY the same.
    Also:
    PHP:
    $dir $player->getDirectionVector();
    $frontPos $player->add($player->getDirectionVector()->multiply(1));
    If you actually have written the code yourself, most people would have done:
    PHP:
    $frontPos $player->add($dir->multiply(1));
    If you don't know how to use it, don't copy it. You clearly don't know.
    Edit: I have deleted that post so that this does not occur again. Moderators can still see the deleted posts, so let's leave it to them. I still have the code, so it wouldn't really matter, either.
    Last edited: Jan 21, 2016
    XFuryMCPE likes this.
  15. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Actually it should be "Item"
  16. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    this is my problem...
    i wanna spawn item and give it parameters such as id or damage , but when i try to do that i am getting a crash because its an entity....
  17. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Can you tell me what this is for?
    PHP:
           $frontPos $player->add($player->getDirectionVector()->multiply(1));
  18. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
  19. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    i know its silly to leave it in my code
    it was no 1 it was 1,5 or something like that, i used this code in my other plugin...
  20. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    That's very funny, I also had 1.5 too.

Share This Page

Advertisement