Shooting hearts

Discussion in 'Plugin Development' started by Sweatyyyy, Nov 22, 2013.

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

    Sweatyyyy

    How would I make so when I right click with a bone, it will shoot a line of hearts in the direction the player is facing? (like the hypixel TNT Wizards VIP+ Blood wand)?

    I know how to do the interact with Bone thing, I just need to know how to do the hearts :)

    Thank you!
     
  2. Offline

    Garris0n

    A BlockIterator and some nms to spawn hearts since Bukkit doesn't have them afaik.
     
  3. Offline

    DarkBladee12

    Sweatyyyy likes this.
  4. Offline

    Sweatyyyy

    DarkBladee12
    Thank you,
    How would I make it so it shoots out of the bone? I have this so far:
    Code:
    @EventHandler
        public void onInteract(PlayerInteractEvent event){
            Player player = event.getPlayer();
            if(player.getItemInHand().getType() == Material.BONE){
                if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK){
                    double health = player.getHealth();
                    int hunger = player.getFoodLevel();
                    if(health <= 5){
                        player.sendMessage("§cNot enough health!");
                        return;
                    }
                    if(hunger <= 5){
                        return;
                    }
                    if(health > 5){
                        player.setHealth(health - 5);
                        player.setFoodLevel(hunger - 5);
                        player.getLocation().getWorld().createExplosion((Location) player.getTargetBlock(null, 50), this.getConfig().getInt("ExplosionSize"));
                        ParticleEffect.HEART.display(WHAT GOES HERE?, 0, 0, 0, 5, 50);
                    }
                }
            }
        }
     
  5. Offline

    M0n0clink

    Sweatyyyy In the class library , it asks for a location for the first argument. Perhaps you can try the following. Thank me later if it helped.
    Code:java
    1. ParticleEffect.HEART.display(player.getLocation(), 0, 0, 0, 5, 50);
    2.  
     
  6. Offline

    DarkBladee12

    Sweatyyyy Why are you casting player.getTargetBlock(null, 50) to a location? You should rather use
    player.getTargetBlock(null, 50).getLocation(). For the beam you would have to add this:

    Code:java
    1. for (Block b : player.getLineOfSight(null, 50))
    2. ParticleEffect.HEART.display(b.getLocation(), 0.1F, 0.1F, 0.1F, 0, 10);
     
Thread Status:
Not open for further replies.

Share This Page