How to change mob drops?

Started by FireBlast on

Topic category: Help with Minecraft modding (Java Edition)

Active 8 years ago
Joined Apr 2015
Points:
719

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 2
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.

Active 3 years ago
Joined May 2015
Points:
830

User statistics:

  • Modifications: 6
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 74
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

Active 8 years ago
Joined Apr 2015
Points:
719

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 2
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?

Active 11 months ago
Joined Aug 2013
Points:
1162

User statistics:

  • Modifications: 4
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 737
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%.

Active 8 years ago
Joined Apr 2015
Points:
719

User statistics:

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

@#2 Thanks

Active 8 years ago
Joined Jun 2016
Points:
704

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1
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. 

Active 11 months ago
Joined Aug 2013
Points:
1162

User statistics:

  • Modifications: 4
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 737
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)?

Active 8 years ago
Joined Nov 2016
Points:
699

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1
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?

Active 11 months ago
Joined Aug 2013
Points:
1162

User statistics:

  • Modifications: 4
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 737
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

Active 7 years ago
Joined Nov 2016
Points:
881

User statistics:

  • Modifications: 0
  • Forum topics: 21
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 155
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.

Active 7 years ago
Joined Nov 2016
Points:
881

User statistics:

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

This does not work in 1.7.1

Active 11 months ago
Joined Aug 2013
Points:
1162

User statistics:

  • Modifications: 4
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 737
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.

Active 5 years ago
Joined Jul 2016
Points:
704

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
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

Active 5 years ago
Joined Jul 2016
Points:
704

User statistics:

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

lol *add

Active 8 years ago
Joined Jul 2015
Points:
712

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 2
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