Make Pigs Poop!

Discussion in 'Plugin Development' started by chriztopia, Dec 22, 2011.

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

    chriztopia

    I would like to be able have a mob drop an item like say a Pig Drop Bread. I ultimatly want to make a new item and have the pig poop while its walking around. but for now just bread. Any help? I do know a scheduler will be needed but how to make the pig mob drop an item?
     
  2. Offline

    nisovin

    Just spawn the item at the pig's location. The pig can't actually drop the item itself, but it will look the same.
     
  3. Offline

    chriztopia

    Ok im trying to just do right click on pig and make it drop bread but its not working.
    Code:
       public void onPlayerInteractEntity(PlayerInteractEntityEvent event){
    
           Entity pp = event.getRightClicked();
    
           if(event.getRightClicked() instanceof Pig){
           pp.getWorld().dropItem(pp.getLocation(), new ItemStack(Material.BREAD,4));
           pp.getWorld().playEffect(pp.getLocation(), Effect.SMOKE, 20);
           }
       }
     
  4. Offline

    AbdulAbdalla

    You can use the onEntityDeath event for natural looking drops.
     
  5. Offline

    efstajas

    Sorry for nonsense, but if you would have called the thread "make pigs poop", the thread would have gotten many more views. :D
     
  6. Offline

    chriztopia

    Fixed Changed thread to Make Pigs poop... lol I agree that would make me want to read it.
     
  7. Offline

    Chiller

    I am like this looks interesting! But idk how to do it...
     
  8. Offline

    chriztopia

    I just need to know how to make a mob drop an item. just for starters i`m trying to do a right click and the mob drop that way I can make it drop anytime I want for testing. I will also be creating a bukkitdev for this for everyone to use this.

    Ok, I now realize what I did wrong I forgot to register the event... stupid me. Heres the code for anyone who would like to use it. now I need to know schedulers I am going to read up on it.

    Code:
       public void onPlayerInteractEntity(PlayerInteractEntityEvent event){
    
           Entity pp = event.getRightClicked();
    
           if(event.getRightClicked() instanceof Pig){
           pp.getWorld().dropItem(pp.getLocation(), new ItemStack(Material.BREAD,1));
           pp.getWorld().playEffect(pp.getLocation(), Effect.SMOKE, 20);
           }
       }
        
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  9. Offline

    ArcheCane

    What is it with minds these days?
     
  10. Offline

    bergerkiller

    *randomly scrolls through plugin development section*
    Make Pigs Poop!
    Hey, that's new...but wha?

    Anyway, to drop an item from a mob, you can use world.dropItemNaturally and drop from the pig location.
    Code:
    Entity e = event.getEntity();
    e.getWorld().dropItemNaturally(e.getLocation(), new ItemStack(Material.WOOL, 1, 12));
     
  11. Offline

    ItsHarry

    Make pigs poop? Haha, thats a pretty cool idea
     
  12. Offline

    chriztopia

    If I can get the plugin approved by bukkitdev I wil start work on it for release. :) Seems like everyone likes the idea. Any help on using the scheduler would work great.
     
Thread Status:
Not open for further replies.

Share This Page