Posted April 10, 201312 yr Hello, I've been trying to put bones to a vanilla mob. I did some research, and tried this: @ForgeSubscribe public void playerKilledSheep(LivingDropsEvent event) { System.out.println("Killed something"); if(event.entityLiving instanceof EntitySheep) { System.out.println("Killed a Sheep"); event.entityLiving.dropItem(Item.bone.shiftedIndex, 1); } } I have an error on the "shiftedIndex" part, but it doesn't even post something in the console, means it doesn't even detect if I killed something or not. Please help. Best regards, MarioErmando
May 18, 201312 yr Since I'm nice I'm going to make this the EASY way. package your.package; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.passive.EntitySquid; import net.minecraft.item.Item; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDropsEvent; public class Event_LivingDrops { public static double rand; @ForgeSubscribe public void onEntityDrop(LivingDropsEvent event) { if (event.source.getDamageType().equals("player")) { //Checks for Damage Type. rand = Math.random(); //Initializes double "rand" System.out.println("Killed something."); if (event.entityLiving instanceof EntitySheep) { //Checks the entity killed. System.out.println("Killed a sheep."); if (rand < 1D) { //Makes drop 100% drop chance. Example: (0.25D = 25%, 1D = 100%, etc.); event.entityLiving.dropItem(Item.bone.itemID); //Use "itemID" not "shiftedIndex" //itemID is used for MCP, shiftedIndex is only used when already converted to .class. } } } } } Also, remember to put this in your Proxy class. You need to register this class for Forge to be able to know it is an event. Put it in the @Init of your proxy. MinecraftForge.EVENT_BUS.register(new Event_LivingDrops()); This should work! Read the "//"s for information. Good Luck!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.