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

How to spawn PrimedTNT?

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

Thread Status:
Not open for further replies.
  1. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Hello again friends, I just want to spawn PrimedTNT entity using command. Please help if you know.
  2. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Here is my code , but it don't work , help me.
    <?php
    namespace Oleg;
    use pocketmine\plugin\PluginBase;
    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    use pocketmine\math\Vector3;
    use pocketmine\Player;
    use pocketmine\level\Position;
    use pocketmine\level;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerInteractEvent;
    use pocketmine\level\particle\EnchantmentTableParticle;
    use pocketmine\item\Item;
    use pocketmine\inventory\PlayerInventory;
    use pocketmine\entity\Entity;
    use pocketmine\entity\PrimedTNT;


    class PixelTestPlugin extends Pluginbase implements Listener{
    public function onEnable(){
    $this->getLogger()->info("Плагин Pixelinfo запуск........");
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
    }

    public function onDisable(){
    $this->getLogger()->info("Плагин Pixelinfo отключение........");
    }
    public function onEvent(PlayerInteractEvent $event)
    {
    if($event->getAction() == PlayerInteractEvent::RIGHT_CLICK_AIR){
    if($player->getInventory()->getItemInHand()->getId() == "287") {
    $speed = 3;
    $pos = $player->getPosition();
    $dir = $player->getDirectionVector();
    $frontPos = $player->add($player->getDirectionVector()->multiply(1.5));
    $dir->x = $dir->x * $speed;
    $dir->y = $dir->y * $speed;
    $dir->z = $dir->z * $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("PrimedTNT", $pos->getLevel()->getChunk($pos->x >> 4, $pos->z >> 4),$nbt)->spawnTo($player);

    }
    }
    }
    }

    ?>
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    First of all, don't compare an item ID against a string.
  4. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    so please change my code i dont know the primed tnt id it is an entity
  5. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    It seems that you don't even understand what he is saying there, and being unable to fix the code yourself. I am surprised that you have written the code. He is not talking about PrimedTNT ID.
  6. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    oh ok...
  7. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    First, use
    Code:
    [PHP] code [/PHP]
    
Thread Status:
Not open for further replies.

Share This Page

Advertisement