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.
  5. This is from MobCatcher.

    Code (Text):
    2. public void playerThrowEvent(Player player){
    4.         ItemStack eggItem = player.getItemInHand();
    5.         ItemStack throwStack = new ItemStack(eggItem);
    6.         throwStack.setAmount(1);
    7.         int amt = eggItem.getAmount();
    8.         Location pLoc = player.getEyeLocation();
    10.         Item thrownEggItem = player.getWorld().dropItem(pLoc, throwStack);
    11.         thrownEggItem.setVelocity(pLoc.getDirection());
    13.          eggItem.setAmount(amt - 1);
    14.          player.setItemInHand(eggItem);
    16.         }
    PogoStick29 and comniemeer like this.
  6. ooooh, thats where the drop item method is. I tried using the player object, and it didnt work. Good job :3

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


    Wait, I need help, how do I set the item to a Slime ball
  11. 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
  12. Offline


  13. Offline


    Guys is there a way to return the location where the eggItem used to arive?
  14. Err.. I would use runnables as there is no EntityMoveEvent.
  15. 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.
  16. 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.
  17. Offline


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


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

Share This Page