Posted October 6, 201311 yr I've just recently figured out how to make this work, after many hours of searching the internet and help forums. So if any of you have had the same problem and faced the same frustration as I have, let me help you out by giving you an example of working code. public class CustomDrops { public static double rand; @ForgeSubscribe public void onEntityDrop(LivingDropsEvent event) { if (event.entityLiving instanceof EntityCreeper){ rand = Math.random(); if (rand < 0.1D) { event.entityLiving.dropItem(TutorialMod.CreeperHeart.itemID, 1); } } } } The number in (rand < 0.1D) is how often you want the item to drop. 1D = 100% so .5D is 50% and so on. The number after your item is how many of that Item you want the mob to drop. You have to make a new class to put this in and then register this event in your main class like this: MinecraftForge.EVENT_BUS.register(new CustomDrops()); You have to put this in your "public void load" constructor. Hope this helps someone!
October 6, 201311 yr check damage type: if(event.source == event.source.inFire || event.source == event.source.onFire || event.source == event.source.lava){ if (event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntityPigZombie) { if (RandomUtil.randomPercent() < 0.25D) { event.entityLiving.dropItem(Foods.foodCookedFlesh.itemID, RandomUtil.getRandom().nextInt(2) + 1); } } }
October 8, 201311 yr Author That is really useful. I'll probably try to use that at some point. Thank you!
October 8, 201311 yr Also, with your example, you are working with a null pointer, i.e. rand. You never give rand a value, you might want to change that I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
October 12, 201311 yr Author Can you give me a good example of what you mean with the null pointer? I work best with visual examples. Are you talking about this? rand = Math.random();
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.