Solved How to code a Tipped Arrow with an effect?

Discussion in 'Plugin Development' started by Mr. Sandwich, Jul 22, 2016.

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

    Mr. Sandwich

    So I coded an ItemStack of a tipped arrow but I cant find a way to apply potion effects on it, what's the way to do that?

    Thanks in advance
     
  2. Offline

    Sethburster

    @Mr. Sandwich You need to first get the item meta before you can apply potion effects.
     
  3. Offline

    Mr. Sandwich

    ...
    I know its basic but what do I do after that, the question was how to apply the potion effects not what you need to do before that
     
    iDimaBR likes this.
  4. Offline

    Mr. Sandwich

  5. that method is from the tipped arrow entity. I dont know if there is a way to set it to the ItemStack, but maybe you can add the effects when the arrow spawn
     
  6. Offline

    Mr. Sandwich

    I need it to be the right type of tipped arrow in the player's inventory not when it spawns, if anyone knows how to do this please comment

    EDIT: I found the solution by myself, you just need to change the meta type to Potion Meta but now I have another question. How do I get this arrow when its shot? I want it to explode when it hits the ground but how can I tell the server that this is this specific arrow?
     
    Last edited: Jul 24, 2016
  7. Offline

    CyberSoul

    I don't know if this is possible with the arrows... It may be possible by giving the bow a lore value and then doing "EntityShootBowEvent" and checking the lore on the bow used... idk if that's what you want though.
     
  8. Offline

    Lordloss

    You should be able to do this with the ProjectileHitEvent.
     
  9. Offline

    Mr. Sandwich

    But how do I detect that this is the right arrow...
     
  10. Offline

    timtower Administrator Administrator Moderator

  11. Offline

    Mr. Sandwich

  12. Offline

    timtower Administrator Administrator Moderator

    @Mr. Sandwich There is probably a way to find that using temporary storage of the amount and stacks, can't come up with a solid system now though.
     
  13. @Mr. Sandwich
    That method returns the Arrow's UUID. What you should do is:
    • Subscribe to the EntityShootBowEvent.
    • Check if the item being shot is your item.
    • Store the UUID of the fired Arrow entity.
    • In the ProjectileHitEvent, check if the UUID of the arrow that hit is the same as one you stored, if it is, then you know it's your arrow
     
  14. Offline

    Mr. Sandwich

    Thanks, solved.
     
Thread Status:
Not open for further replies.

Share This Page