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

Custom Projectiles?

Comments in 'Plugin Development' started by Legoboy0215, Jul 24, 2015.

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

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Is it possible to make custom projectiles?
    jojoe77777 likes this.
  2. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I don't know how, but you can use potatoes like projectiles, so it is possible ;)
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    he can use all items as projectile ;)
  4. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    code by PEMapModder:
    PHP:
                            $aimPos $player->getDirectionVector();$nbt = new Compound("", ["Pos" => new Enum("Pos", [
     new 
    Double(""$player->x),
     new 
    Double(""$player->$player->getEyeHeight()),
     new 
    Double(""$player->z)
     ]),
    "Motion" => new Enum("Motion", [
     new 
    Double(""$aimPos->x),
     new 
    Double(""$aimPos->y),
     new 
    Double(""$aimPos->z)
     ]),
    "Rotation" => new Enum("Rotation", [
     new 
    Float(""$player->yaw),
     new 
    Float(""$player->pitch)
     ]),
    "Health" => new Short("Health"5),"Item" => new Compound("Item", ["id" => new Short("id"Item::EMERALD),"Damage" => new Short("Damage"0),"Count" => new Byte("Count"1),
     ]),
    "PickupDelay" => new Short("PickupDelay"0x7F),
     ]);
    $f 1.5;$emeraldEntity::createEntity("Item"$player->getLevel()->getChunk($player->getFloorX() >> 4$player->getFloorZ() >> 4), $nbt$player);$emerald->setMotion($snowball->getMotion()->multiply($f));
     if(
    $player->isSurvival()){$item->setCount($item->getCount() - 1);$player->getInventory()->setItemInHand($item->getCount() > $item Item::get(Item::AIR));
     }
    $player->getLevel()->addSound(new LaunchSound($player), $player->getViewers());$emerald->spawnToAll();
     }
    TigerHix and Legoboy0215 like this.
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    you only add motion to item
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Then what should I do with
    PHP:
                            $aimPos $player->getDirectionVector();$nbt = new Compound("", ["Pos" => new Enum("Pos", [
    new 
    Double(""$player->x),
    new 
    Double(""$player->$player->getEyeHeight()),
    new 
    Double(""$player->z)
    ]),
    "Motion" => new Enum("Motion", [
    new 
    Double(""$aimPos->x),
    new 
    Double(""$aimPos->y),
    new 
    Double(""$aimPos->z)
    ]),
    "Rotation" => new Enum("Rotation", [
    new 
    Float(""$player->yaw),
    new 
    Float(""$player->pitch)
    ]),
    "Health" => new Short("Health"5),"Item" => new Compound("Item", ["id" => new Short("id"Item::EMERALD),"Damage" => new Short("Damage"0),"Count" => new Byte("Count"1),
    ]),
    "PickupDelay" => new Short("PickupDelay"0x7F),
    ]);
    $f 1.5;$emeraldEntity::createEntity("Item"$player->getLevel()->getChunk($player->getFloorX() >> 4$player->getFloorZ() >> 4), $nbt$player);$emerald->setMotion($snowball->getMotion()->multiply($f));
    if(
    $player->isSurvival()){$item->setCount($item->getCount() - 1);$player->getInventory()->setItemInHand($item->getCount() > $item Item::get(Item::AIR));
    }
    $player->getLevel()->addSound(new LaunchSound($player), $player->getViewers());$emerald->spawnToAll();
    }
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    you can edit it
    do you want throw custom projectile right?
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    yes
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    so use this code
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Where should I add it?
  11. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Does it need to be some event or what? IDK where to put the whole code.
  12. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    yes you must call it on event, command or task
  13. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Then what? I call it on a command then I can start throwing stuff?
  14. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    if you want to throw it like snowball use interact event
  15. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    So on iyeract with air then execute this piece of code. This will result flying emeralds?
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why do you ask "where should this code be at?" That means you don't understand. Don't copy if you don't understand.
  17. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11

    Crashed , Except it happened when I threw it

    PocketMine-MP Crash Dump Thu Aug 6 08:30:38 AKDT 2015

    Error: Undefined class constant 'EMERALD'
    File: /EmeraldCannon/src/SM11/EmeraldCannon/Main
    Line: 40
    Type: E_ERROR

    THIS CRASH WAS CAUSED BY A PLUGIN
    BAD PLUGIN: EmeraldCannon v1.0.0

    Code:
    [31] new Double("", $player->y + $player->getEyeHeight()),
    [32] new Double("", $player->z)
    [33] ]),"Motion" => new Enum("Motion", [
    [34] new Double("", $aimPos->x),
    [35] new Double("", $aimPos->y),
    [36] new Double("", $aimPos->z)
    [37] ]),"Rotation" => new Enum("Rotation", [
    [38] new Float("", $player->yaw),
    [39] new Float("", $player->pitch)
    [40] ]),"Health" => new Short("Health", 5),"Item" => new Compound("Item", ["id" => new Short("id", Item::EMERALD),"Damage" => new Short("Damage", 0),"Count" => new Byte("Count", 1),
    [41] ]),"PickupDelay" => new Short("PickupDelay", 0x7F),
    [42] ]);$f = 1.5;$emerald= Entity::createEntity("Item", $player->getLevel()->getChunk($player->getFloorX() >> 4, $player->getFloorZ() >> 4), $nbt, $player);$emerald->setMotion($snowball->getMotion()->multiply($f));
    [43] if($player->isSurvival()){$item->setCount($item->getCount() - 1);$player->getInventory()->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
    [44] }$player->getLevel()->addSound(new LaunchSound($player), $player->getViewers());$emerald->spawnToAll();
    [45]
    [46] }
    [47] }
    [48]
    [49]
    [50]

    Backtrace:
    #0 /src/pocketmine/Server__32bit(0): pocketmine\Server->crashDump()
    #1 /src/pocketmine/plugin/MethodEventExecutor(36): SM11\EmeraldCannon\Main->onInteract()
    #2 /src/pocketmine/plugin/RegisteredListener(96): pocketmine\plugin\MethodEventExecutor->execute()
    #3 /src/pocketmine/plugin/PluginManager(673): pocketmine\plugin\RegisteredListener->callEvent()
    #4 /src/pocketmine/Player__32bit(1966): pocketmine\plugin\PluginManager->callEvent()
    #5 /src/pocketmine/network/RakLibInterface(140): pocketmine\Player->handleDataPacket()
    #6 /src/raklib/server/ServerHandler__32bit(90): pocketmine\network\RakLibInterface->handleEncapsulated()
    #7 /src/pocketmine/network/RakLibInterface(79): raklib\server\ServerHandler->handlePacket()
    #8 /src/pocketmine/network/Network(146): pocketmine\network\RakLibInterface->process()
    #9 /src/pocketmine/Server__32bit(2474): pocketmine\network\Network->processInterfaces()
    #10 /src/pocketmine/Server__32bit(2291): pocketmine\Server->tick()
    #11 /src/pocketmine/Server__32bit(2169): pocketmine\Server->tickProcessor()
    #12 /src/pocketmine/Server__32bit(1774): pocketmine\Server->start()
    #13 /src/pocketmine/PocketMine(464): pocketmine\Server->__construct()
    #14 (1): ()
    #15 (0): {main}()

    PocketMine-MP version: 1.5dev #1232 [Protocol 27; API 1.12.0]
    Git commit: 0000000000000000000000000000000000000000
    uname -a: Windows NT ASUS-LAPTOP 6.2 build 9200 (Windows 8 Home Premium Edition) i586
    PHP Version: 5.6.6
    Zend version: 2.6.0
    OS : WINNT, win
  18. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  19. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    Here you Go.

    <?php

    namespace SM11\EmeraldCannon;
    use pocketmine\plugin\PluginBase;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerInteractEvent;
    use pocketmine\math\Vector2;
    use pocketmine\nbt\tag\Compound;
    use pocketmine\nbt\tag\Enum;
    use pocketmine\nbt\tag\Double;
    use pocketmine\nbt\tag\Float;
    use pocketmine\nbt\tag\Short;
    use pocketmine\entity\Item;


    class Main extends PluginBase implements Listener{

    public function onEnable(){
    $this->getServer()->getPluginManager()->registerEvents($this, $this);
    $this->getLogger()->info("EmeraldCannon enabled!");
    }

    public function onDisable(){
    $this->getServer()->getPluginManager()->registerEvents($this, $this);
    $this->getLogger()->info("EmereldCannon Disabled!");
    }

    public function onInteract(PlayerInteractEvent $player){
    $player = $player->getPlayer();
    $aimPos = $player->getDirectionVector();$nbt = new Compound("", ["Pos" => new Enum("Pos", [
    new Double("", $player->x),
    new Double("", $player->y + $player->getEyeHeight()),
    new Double("", $player->z)
    ]),"Motion" => new Enum("Motion", [
    new Double("", $aimPos->x),
    new Double("", $aimPos->y),
    new Double("", $aimPos->z)
    ]),"Rotation" => new Enum("Rotation", [
    new Float("", $player->yaw),
    new Float("", $player->pitch)
    ]),"Health" => new Short("Health", 5),"Item" => new Compound("Item", ["id" => new Short("id", Item::EMERALD),"Damage" => new Short("Damage", 0),"Count" => new Byte("Count", 1),
    ]),"PickupDelay" => new Short("PickupDelay", 0x7F),
    ]);$f = 1.5;$emerald= Entity::createEntity("Item", $player->getLevel()->getChunk($player->getFloorX() >> 4, $player->getFloorZ() >> 4), $nbt, $player);$emerald->setMotion($snowball->getMotion()->multiply($f));
    if($player->isSurvival()){$item->setCount($item->getCount() - 1);$player->getInventory()->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
    }$player->getLevel()->addSound(new LaunchSound($player), $player->getViewers());$emerald->spawnToAll();

    }
    }
Thread Status:
Not open for further replies.

Share This Page

Advertisement