Making items throwable?

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

  1. Offline

    Theodossis

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I am making a plugin and i want to make slimeballs throwable like egg.
    Thanks,
    Theodossis
  2. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    Loog

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I have also been wondering how you would do this.
    @CorrieKay How would we do that? code?
  4. Offline

    Malikk

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    That's how I've done it in the past. Pretty simple actually.
  5. Offline

    Malikk

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This is from MobCatcher.

    Code:
    public void playerThrowEvent(Player player){
            
            ItemStack eggItem = player.getItemInHand();
            ItemStack throwStack = new ItemStack(eggItem);
            throwStack.setAmount(1);
            int amt = eggItem.getAmount();
            Location pLoc = player.getEyeLocation();
            
            Item thrownEggItem = player.getWorld().dropItem(pLoc, throwStack);
            thrownEggItem.setVelocity(pLoc.getDirection());
    
             eggItem.setAmount(amt - 1);
             player.setItemInHand(eggItem);
    
            }
    
    PogoStick29 and comniemeer like this.
  6. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    ooooh, thats where the drop item method is. I tried using the player object, and it didnt work. Good job :3
  7. Offline

    Firefly

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME

    Don't forget dropItemNaturally() is there as well for a more "natural" looking drop :D
  8. Offline

    Malikk

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    dropItemNaturally wouldn't be good in this situation, since we want to set it's velocity to a specific direction.
  9. Offline

    Firefly

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I know, I was just pointing out to Corrie ;)
    CorrieKay likes this.
  10. Offline

    willis62501

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Wait, I need help, how do I set the item to a Slime ball
  11. Offline

    Garris0n

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  12. Offline

    willis62501

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @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
  13. Offline

    Garris0n

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  14. Offline

    willis62501

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME

Share This Page