Solved Get egg from projectilehitevent

Discussion in 'Plugin Development' started by MisterErwin, Mar 30, 2013.

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

    MisterErwin

    Hello together,

    how can I get the player and the egg (ItemStack) from the projectilehitevent ?

    I would like to get the DisplayName from the egg that had been throwen.

    Is that possible?

    Thank you very much,

    MisterErwin
     
  2. Offline

    Nitnelave

    You have to understand that there is a difference between an egg in the inventory (itemstack) and a thrown egg (entity). So you can do a homemade conversion (e.g. new ItemStack(Material.EGG)).
    An entity has no display name (as far as I'm aware), so you will have to get the display name from the itemstack you just created. And you still have the problem of the player.

    A better solution would be to store all that information into some hashmap in the playerShootEvent (or similar) and associate that with the unique ID given to the thrown egg. Then in the projectileHitEvent, you just have to retrieve the info from the hashmap.
     
  3. Offline

    MisterErwin

    Yes... I've founded a way: Currently I'm storing the Name via MetaData at the entity-egg - But thanks
     
Thread Status:
Not open for further replies.

Share This Page