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

Solved Help.

Comments in 'Plugin Development' started by CavinMiana, Oct 20, 2015.

  1. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Hello,

    I want to use a fishing rod to throw snowballs. This is what I have so far.
    PHP:
    public function onInteract(PlayerInteractEvent $ev) {
            
    $player $ev->getPlayer();
           
            if (
    $ev->getAction() == PlayerInteractEvent::LEFT_CLICK_AIR and $ev->getItem()->getId() === 476){
        
         
                
    $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::SNOWBALL),
                                   
    "Damage" => new Short("Damage"5),
                                   
    "Count" => new Byte("Count"1),
                               ]),
                               
    "PickupDelay" => new Short("PickupDelay"0x7F),
                            ]);
                            
    $f 1.5;
                            
    $item $ev->getItem();
                            
    $snowball Entity::createEntity("Item"$player->getLevel()->getChunk($player->getFloorX() >> 4$player->getFloorZ() >> 4), $nbt$player);
                            
    $snowball->setMotion($snowball->getMotion()->multiply($f));
                            if(
    $player->isSurvival()){
                                
    $item->setCount($item->getCount() - 1);
                                
    $player->getInventory()->setItemInHand($item->getCount() > $item Item::get(Item::FISHING_ROD));
                            }
                            
    $player->getLevel()->addSound(new LaunchSound($player), $player->getViewers());
                            
    $snowball->spawnToAll();
            }
        }
    }
    But when tap the fish button thing it does not throw a snowball. Any help?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    LEFT_CLICK_AIR means just pressing somewhere in the air, not the fish button
  3. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Nvm I got this sorry putting solved now.

Share This Page

Advertisement