I made a little debugging part for my mod, and it's working great. Basically, it just prints how much leather the zombie drops. But it prints 2 sometimes, but the zombie only drops 1 leather.
Hey, is there a way to remove drops from mobs? Also I can't seem to get this called when I kill something, I am registering it as "FMLCommonHandler.instance().bus().register(new DropHandler());" in my main class.
Hey, is there a way to remove drops from mobs? Also I can't seem to get this called when I kill something, I am registering it as "FMLCommonHandler.instance().bus().register(new DropHandler());" in my main class.
Any help would be great, thanks!
The LivingDropsEvent handling should be registered to MinecraftForge.EVENT_BUS.register().
You can tell what bus the event should be registered to by looking at the package it belongs to. In this case the class is net.minecraftforge.event.entity.living.LivingDropsEvent which is on the minecraftforge event bus (obviously)
In contrast the ItemCraftedEvent is in cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent so would be registered to the FML bus.
DropHandler
package deathman12e3.MoreDrops;
import java.util.Random;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
public class DropHandler
{
public static Random random;
public static int dropped;
@ForgeSubscribe
public void onEntityDrop(LivingDropsEvent event)
{
random = new Random();
dropped = random.nextInt(2) + 1;
//event.entityLiving.dropItem(par1, par2)
if(event.entityLiving instanceof EntityZombie)
{
if(event.entityLiving.isBurning() == false)
{
event.entityLiving.entityDropItem(new ItemStack(Item.leather), dropped);
if(mod_MoreDrops.debugging == true)
{
System.out.println(dropped);
}
}
}
}
}
Any help would be great, thanks!
The LivingDropsEvent handling should be registered to MinecraftForge.EVENT_BUS.register().
You can tell what bus the event should be registered to by looking at the package it belongs to. In this case the class is net.minecraftforge.event.entity.living.LivingDropsEvent which is on the minecraftforge event bus (obviously)
In contrast the ItemCraftedEvent is in cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent so would be registered to the FML bus.