How to change what a mob drops?

Discussion in 'Plugin Development' started by MrTurtle, Apr 12, 2014.

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

    MrTurtle

    How can I change what a mob drops like a pig or a sheep?
     
  2. Offline

    Onlineids

    on the event that that mob dies get the drops and edit to your liking
     
  3. Offline

    MrTurtle

    Onlineids
    Could you give a example? Its ok if you dont want to
     
  4. Offline

    zDylann


    Code:java
    1. @EventHandler
    2. public void onMobDeath(EntityDeathEvent event){
    3. //If the killer is a plyer
    4. if(event.getEntity().getKiller() instanceof Player){
    5. //If the mob is a creeper
    6. if(event.getEntity().getType() == EntityType.CREEPER){
    7. //add a diamond!
    8. event.getDrops().add(new ItemStack(Material.DIAMOND, 1));
    9. }
    10. }
    11. }
     
  5. Offline

    MrTurtle

  6. Offline

    ftfc

    How does one add a percentage chance of that drop occurring?
     
  7. Offline

    thomasb454

    @ftfcPlease create your own thread when you have other questions, but anyway use a Random (Google will help you).
     
Thread Status:
Not open for further replies.

Share This Page