How to change mob drops?

Started by FireBlast on

Topic category: Help with modding (Java Edition)

Last seen on 01:19, 22. Jul 2016
Joined Apr 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to change mob drops?

I want that a zombie drop rotten flesh and bones, and the chicken just drops raw chicken.

Is there some way to change the mobs drops?

P.S: Sorry for my bad English, i'm not from US or UK.

Last seen on 20:30, 30. Jun 2021
Joined May 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ok if you mean normal
Sun, 11/22/2015 - 20:07

ok if you mean normal minecraft zombies and chickens then you can do that but if you had made your own zombie and chicken you can put those drop

Last seen on 01:19, 22. Jul 2016
Joined Apr 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:ok if you mean normal
Sun, 11/22/2015 - 22:17

@#1 OK, but if i create a new zombie and a new chicken, the original ones will drop they original drop. How can i delete them, or something else?

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You DON'T must make new mobs.
Sun, 11/22/2015 - 23:04

You DON'T must make new mobs. You can easily edit the vanilla mobs.

Make new overlay. There don´t edit anything and click "finish" or "next".

View source of this "Overlay". Remove some things. You need your "overlay" class looks like this: 

[spoiler]import ..........

public class mcreator_overlayTest{

public static class GUIRenderEventClass
{}

public mcreator_overlayTest(){}

public Object instance;
public void load(FMLInitializationEvent event){
    MinecraftForge.EVENT_BUS.register(new GUIRenderEventClass());
    
     
}
public void generateNether(World world, Random random, int chunkX, int chunkZ){}
public void generateSurface(World world, Random random, int chunkX, int chunkZ){}
public int addFuel(ItemStack fuel){return 0;}
public void serverLoad(FMLServerStartingEvent event){}
public void preInit(FMLPreInitializationEvent event){}
public void registerRenderers(){}
}[/spoiler]

to the public static class GUIRenderEventClass
add:

  public void playerKilledZombie(LivingDropsEvent event)
   {
      if(event.entityLiving instanceof EntityZombie)
      {

        

        event.entityLiving.dropItem(Items.rotten_flesh, 1);

         event.entityLiving.dropItem(Items.bone, 1);
        
      }
    
}


Now the zombie will drop rotten flesh and bone.

 

For the chicken under previous text add:

@SubscribeEvent
public void playerKilledChicken(LivingDropsEvent event)
   {
      if(event.entityLiving instanceof EntityChicken)
      {

         event.drops.clear();
         ItemStack itemStackToDrop = new ItemStack(Items.chicken, 1);
         event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, 
              event.entity.posY, event.entity.posZ, itemStackToDrop));

       
        
      }
    
}

And that's all! And yes i tested it and this method works on 100%.

Last seen on 01:19, 22. Jul 2016
Joined Apr 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You DON'T must make new mobs.
Sun, 11/22/2015 - 23:05

@#2 Thanks

Last seen on 17:02, 6. Jul 2016
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You DON'T must make new mobs.
Sun, 06/19/2016 - 07:52

@#2 Can you help me on how to change the drops of a cow? I made a custom item (Cowhide) and I want to replace cows dropping leather to dropping my custom item. I tried copying the code you put up and changing certain things but it just failed. 

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:You DON'T must make new mobs.
Sun, 06/19/2016 - 22:27

@#2.2 1st - was the class "Event Handler" (or simplier - empty GUI Overlay) ?
2nd - what exactly do you mean by "it just failed"?

3rd - can I see your code + crash log (if there is any)?

Last seen on 02:36, 4. Dec 2016
Joined Nov 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:You DON'T must make new mobs.
Sun, 11/20/2016 - 23:48

@#2.2.1 I'm doing something similar right now, trying to add a custom item to squid drops.

So far I've changed the code in the overlay as per your instructions and now am here:

public static class GUIRenderEventClass
{ public void playerKilledSquid(LivingDropsEvent event)
   {
      if(event.entityLiving instanceof EntitySquid)
      {

        

        event.entityLiving.dropItem(Items.ink_sac, 1);

         event.entityLiving.dropItem(Items.Xylan, 1);
        
      }
    
}
}

Can you tell me what information I need to properly refer to my custom item, and if there's anything apparently wrong with this code?

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can easily get your
Mon, 11/21/2016 - 06:17

You can easily get your custom item using "mcreator_itemName.block", Also you miss @SubscribeEvent before the void

Last seen on 22:52, 27. Oct 2017
Joined Nov 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Question why does the chicken
Mon, 11/21/2016 - 17:17

Question why does the chicken have to be clearned and why is it a different code then the rest I am confused why the mobs code wouldn't follow a patten.

Last seen on 22:52, 27. Oct 2017
Joined Nov 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This does not work in 1.7.1
Mon, 11/21/2016 - 17:53

This does not work in 1.7.1

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:This does not work in 1.7.1
Mon, 11/21/2016 - 18:23

@#5 It is nothing weird that it does not work , it is for verions 1.8.9-  so is not surprise that Forge changed a bit. Simply they changed for almost all fields in all events access modifiers from public to private , so you must use the getters (etc... getDrops() )

To the first question , is pretty obvious that I talked to the person that made this thread.

 

 

 

I want that a zombie drop rotten flesh and bones, and the chicken just drops raw chicken.

Also they are different because the zombie one just adds an item to the list ,while the chicken removes one.

Last seen on 01:17, 11. Nov 2019
Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I do to an item of my
Sun, 03/19/2017 - 18:33

How do I do to an item of my mod 

do I need to a library

Last seen on 01:17, 11. Nov 2019
Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
lol *add
Sun, 03/19/2017 - 18:34

lol *add

Last seen on 17:09, 29. Mar 2017
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You DON'T must make new mobs.
Wed, 03/29/2017 - 13:26

@#2 sorry for the necro but Nuparu the code you gave has the mob drop the item as long as it's alive rather than when it dies, I figure that might crash your game XD