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

Hold to shoot continuously

Comments in 'Plugin Development' started by QuangDo, Feb 6, 2016.

  1. QuangDo
    Offline

    QuangDo Active Member

    Joined:
    Jun 23, 2015
    Posts:
    66
    Minecraft User:
    QuangDo
    i got this from the old plugin, holding arrows to shoot instead of using bow.
    how to make it keep shooting on pressing?

    Code:
    public function onDataPacketReceive(DataPacketReceiveEvent $event){
            $pk = $event->getPacket();
            if($pk->pid() !== ProtocolInfo::USE_ITEM_PACKET || $pk->face !== 0xff) return false;
            $p = $event->getPlayer();
            $inv = $p->getInventory();
            $i = $inv->getItemInHand();
            if($i->getID() == 262){
                $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $p->x),new Double("", $p->y + $p->getEyeHeight()),new Double("", $p->z)]),"Motion" => new Enum("Motion", [new Double("", -sin($p->getyaw() / 180 * M_PI) * cos($p->getPitch() / 180 * M_PI)),new Double("", -sin($p->getPitch() / 180 * M_PI)),new Double("", cos($p->getyaw() / 180 * M_PI) * cos($p->getPitch() / 180 * M_PI))]),"Rotation" => new Enum("Rotation", [new Float("", $p->getyaw()),new Float("", $p->getPitch())])]);
                $arrow = new Arrow($p->chunk, $nbt, $p);
                $ev = new EntityShootBowEvent($p, Item::get(264, 0, 0), $arrow, 1.5);
                $this->getServer(0)->getPluginManager()->callEvent($ev);
                if($ev->isCancelled()){
                    $arrow->kill();
                }else{
                    $i->setCount($i->getCount() - 1);
                    $inv->setItem($inv->getHeldItemSlot(), $i);               
                    $arrow->spawnToAll();
                }
            }
        }
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    there is no way, the client sends the packet 1 time on air touch, so you should press and hold for a while many times.
    Last edited: Feb 6, 2016
    applqpak and QuangDo like this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Animate packet may help.

Share This Page

Advertisement