Throwable axes & swords/daggers

Discussion in 'Plugin Development' started by ferrago, Apr 16, 2014.

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

    ferrago

    Okay So I am developing a piece of code for weapon types. Where the item can have "Weapon Type: Thrown" in the lore and it will be a throwable weapon so when you right click it throws the item. I did a bit of hackery just to see how feasible this is. So far I have the launch event working fine. I essentially call the World.dropItem() method, and launch an arrow real quick, clone the velocity, and remove the arrow immediately. (I will write an algorithm for calculating velocity better after I get the effect working). I also have it coded so the thrown item is homing. If it is thrown in the general direction it will target a player and actually change the velocity to always hit the player. All of that is working perfectly. Here is my issue, I am unsure how to "detect" when the item hit's a player or the ground. I want to remove it when either happens so the item can't be picked up, but I also want to apply damage if it hits the person. I have spent the past several hours coding the rest of it and am fried, so I am asking for your help Bukkit Community, help me finish this potentially amazing plugin.

    TL;DR: I am "dropping" an item through World.dropItem() how to remove item when it hits the ground, and how to detect when the item hits a player.
     
  2. Offline

    epicfacecreeper

    I would do it a bit differently. I would create an arrow, add some metadata to tell what kind of weapon this is, then make the arrow invisible, and make the item ride it. Then use a projectile hit event and check the metadata.
     
    Mathias Eklund likes this.
  3. Offline

    ferrago

    Well I ended up figuring it out, but thank you. But how would I make the item ride it your way?
     
  4. Offline

    Mathias Eklund

    ferrago you can always try the .setPassenger method. Tho i doubt it will work :)
     
  5. Offline

    qlimax5000

    Create a BukkitRunnable and make a contructor with the Item and then on each run (1 tick delay) check if item.isOnGround() or nearby entities is instanceof Player
     
Thread Status:
Not open for further replies.

Share This Page