Making items throwable?

Discussion in 'Plugin Development' started by Theodossis, Aug 5, 2012.

Thread Status:
Not open for further replies.
  1. I am making a plugin and i want to make slimeballs throwable like egg.
  2. Im guessing you could probably spawn an entity of an item, get the item stack, set the type to slimeball, then set the items velocity. But thats just a (debatably) educated guess.​
    PogoStick29 likes this.
  3. Offline


    I have also been wondering how you would do this.
    CorrieKay How would we do that? code?
  4. That's how I've done it in the past. Pretty simple actually.

    This is from MobCatcher.

    public void playerThrowEvent(Player player){
            ItemStack eggItem = player.getItemInHand();
            ItemStack throwStack = new ItemStack(eggItem);
            int amt = eggItem.getAmount();
            Location pLoc = player.getEyeLocation();
            Item thrownEggItem = player.getWorld().dropItem(pLoc, throwStack);
             eggItem.setAmount(amt - 1);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 27, 2016
  5. ooooh, thats where the drop item method is. I tried using the player object, and it didnt work. Good job :3

  6. Don't forget dropItemNaturally() is there as well for a more "natural" looking drop :D
  7. dropItemNaturally wouldn't be good in this situation, since we want to set it's velocity to a specific direction.
  8. I know, I was just pointing out to Corrie ;)
    CorrieKay likes this.
  9. Offline


    Wait, I need help, how do I set the item to a Slime ball
  10. Offline


    Garris0n I'm still confused, how do I use this stuff, Like how would I code it?

    These JavaDocs just confuse me, I don't know what way to use them
  11. Offline


  12. Offline


    Guys is there a way to return the location where the eggItem used to arive?
  13. Err.. I would use runnables as there is no EntityMoveEvent.
  14. Not sure what you want the the ProjectileHitEvent is called when a projectile hits something. If you want to get the projectile while it is in mid air then you will have to do what ChipDev said and use runnables.
  15. Stop this necromancy! Halloween is over! :p
    EDIT: Plus, this gets the award for the longest time a thread hasn't been marked as solved, but has been necro-posted in twice, as far as I know. Congrats! Here's your trick or treat candy [cake]
    acer5999, Th3Br1x and Skionz like this.
  16. Offline


    Ok However how runnables will help me
  17. Add the projectile to a list and when the scheduler runs, iterate through the list and get the locations of the Projectiles.
  18. Offline


    OK thank you
    Skionz likes this.
Thread Status:
Not open for further replies.

Share This Page