Started by
FireBlast
on
Topic category: Help with Minecraft modding (Java Edition)
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.
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
@#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?
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%.
@#2 Thanks
@#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.
@#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)?
@#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:
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?
You can easily get your custom item using "mcreator_itemName.block", Also you miss @SubscribeEvent before the void
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.
This does not work in 1.7.1
@#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.
Also they are different because the zombie one just adds an item to the list ,while the chicken removes one.
How do I do to an item of my mod
do I need to a library
lol *add
@#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