List of usage examples for net.minecraftforge.event.entity.living LivingDropsEvent getSource
public DamageSource getSource()
From source file:com.buuz135.industrial.proxy.event.MobDeathHandler.java
License:Open Source License
@SubscribeEvent(priority = EventPriority.LOWEST) public void onDeath(LivingDropsEvent event) { if (event.getSource().equals(CommonProxy.custom)) { event.getDrops().clear();/*from w w w . j a v a2 s .com*/ } }
From source file:com.dyonovan.needfulthings.enchantments.EnchantmentBeheading.java
License:Creative Commons License
@SubscribeEvent public void onLivingDropsEvent(LivingDropsEvent event) { DamageSource source = event.getSource(); if (source.getDamageType().equalsIgnoreCase("player") || source.getDamageType().equalsIgnoreCase("arrow")) { EntityPlayer player = null;//from w w w. j av a2 s .c om if (source.getDamageType().equalsIgnoreCase("arrow")) { if (((EntityArrow) event.getSource().getSourceOfDamage()).shootingEntity instanceof EntityPlayer) player = (EntityPlayer) ((EntityArrow) event.getSource().getSourceOfDamage()).shootingEntity; } else player = (EntityPlayer) event.getSource().getSourceOfDamage(); if (player != null) { int level = EnchantmentHelper.getEnchantmentLevel( Enchantment.getEnchantmentByLocation(Reference.MOD_ID + ":" + NAME), player.getHeldItemMainhand()); if (level > 0) { ItemStack skull = getSkullForEntity((EntityLivingBase) event.getEntity()); if (skull != null) { int random = (MathHelper.getRandomIntegerInRange(player.getRNG(), 0, 100) + (level * 10)); //System.out.println(random); if (random >= 80 || skull.getItemDamage() == 3) { if (!event.getDrops().contains(skull)) { World world = player.getEntityWorld(); Entity entity = event.getEntity(); float rx = world.rand.nextFloat() * 0.8F; float ry = world.rand.nextFloat() * 0.8F; float rz = world.rand.nextFloat() * 0.8F; event.getDrops().add(new EntityItem(world, entity.posX + rx, entity.posY + ry, entity.posZ + rz, skull)); } } } } } } }
From source file:de.ellpeck.actuallyadditions.mod.event.CommonEvents.java
@SubscribeEvent public void onEntityDropEvent(LivingDropsEvent event) { if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getEntity() instanceof EntityPlayer) { //Drop Cobwebs from Spiders if (ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntityLiving() instanceof EntitySpider) { if (event.getEntityLiving().world.rand.nextInt(20) <= event.getLootingLevel() * 2) { event.getEntityLiving()// www .j a v a2 s. c o m .entityDropItem(new ItemStack(Blocks.WEB, event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1), 0); } } } }
From source file:de.ellpeck.actuallyadditions.mod.event.EntityLivingEvents.java
@SubscribeEvent public void onEntityDropEvent(LivingDropsEvent event) { if (event.getEntityLiving().worldObj != null && !event.getEntityLiving().worldObj.isRemote && event.getSource().getEntity() instanceof EntityPlayer) { //Drop Solidified XP if (event.getEntityLiving() instanceof EntityCreature) { if (Util.RANDOM.nextInt(10) <= event.getLootingLevel() * 2) { event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemSolidifiedExperience, Util.RANDOM.nextInt(2 + event.getLootingLevel()) + 1), 0); }/*w w w. j av a 2 s. c om*/ } //Drop Cobwebs from Spiders if (ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntityLiving() instanceof EntitySpider) { if (Util.RANDOM.nextInt(20) <= event.getLootingLevel() * 2) { event.getEntityLiving().entityDropItem( new ItemStack(Blocks.WEB, Util.RANDOM.nextInt(2 + event.getLootingLevel()) + 1), 0); } } //Drop Wings from Bats if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat) { if (Util.RANDOM.nextInt(15) <= event.getLootingLevel() * 2) { event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemMisc, Util.RANDOM.nextInt(2 + event.getLootingLevel()) + 1, TheMiscItems.BAT_WING.ordinal()), 0); } } } }
From source file:de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience.java
@SubscribeEvent public void onEntityDropEvent(LivingDropsEvent event) { if (ConfigBoolValues.DO_XP_DROPS.isEnabled()) { if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getEntity() instanceof EntityPlayer) { //Drop Solidified XP if (event.getEntityLiving() instanceof EntityCreature) { if (event.getEntityLiving().world.rand.nextInt(10) <= event.getLootingLevel() * 2) { event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemSolidifiedExperience, event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1), 0); }/*from w w w . ja v a 2 s . c o m*/ } } } }
From source file:de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats.java
@SubscribeEvent public void onEntityDropEvent(LivingDropsEvent event) { if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getEntity() instanceof EntityPlayer) { //Drop Wings from Bats if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat) { if (event.getEntityLiving().world.rand.nextInt(15) <= event.getLootingLevel() * 2) { event.getEntityLiving()//from ww w . j a v a 2 s.co m .entityDropItem(new ItemStack(InitItems.itemMisc, event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1, TheMiscItems.BAT_WING.ordinal()), 0); } } } }
From source file:mod.rankshank.arbitraria.common.loot.HandlerGrabBagDrops.java
@SubscribeEvent public void onDeath(LivingDropsEvent event) { EntityLivingBase src = (EntityLivingBase) event.getEntity(); if (!event.getSource().isCreativePlayer() && event.isRecentlyHit() && rand.nextInt(12 - event.getLootingLevel()) == 0) { double pow = src.getMaxHealth() * (src instanceof IMob ? .2 : .05); pow += event.getLootingLevel();//from w w w .j a v a 2 s . com EnumBagSize size = EnumBagSize.values()[0]; } }
From source file:vazkii.quark.misc.feature.SnowGolemPlayerHeads.java
License:Creative Commons License
@SubscribeEvent public void onDrops(LivingDropsEvent event) { Entity e = event.getEntity(); if (e.hasCustomName() && e instanceof EntitySnowman && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityWitch) { EntitySnowman snowman = (EntitySnowman) e; if (snowman.isPumpkinEquipped()) { ItemStack stack = new ItemStack(Items.SKULL, 1, 3); ItemNBTHelper.setString(stack, "SkullOwner", e.getCustomNameTag()); event.getDrops().add(new EntityItem(e.getEntityWorld(), e.posX, e.posY, e.posZ, stack)); }// w w w.j av a2s . co m } }
From source file:vazkii.quark.tweaks.feature.SnowGolemPlayerHeads.java
License:Creative Commons License
@SubscribeEvent public void onDrops(LivingDropsEvent event) { Entity e = event.getEntity(); if (e.hasCustomName() && e instanceof EntitySnowman && event.getSource().getEntity() != null && event.getSource().getEntity() instanceof EntityWitch) { EntitySnowman snowman = (EntitySnowman) e; if (!snowman.isPumpkinEquipped()) { // for some reason isPumpkinEquipped is backwards ItemStack stack = new ItemStack(Items.SKULL, 1, 3); ItemNBTHelper.setString(stack, "SkullOwner", e.getCustomNameTag()); event.getDrops().add(new EntityItem(e.worldObj, e.posX, e.posY, e.posZ, stack)); }/*w ww. ja va 2s. co m*/ } }
From source file:vazkii.quark.vanity.feature.WitchHat.java
License:Creative Commons License
@SubscribeEvent public void onDrops(LivingDropsEvent event) { if (event.getEntityLiving() instanceof EntityWitch && (!verifyTruePlayer || event.getSource().getTrueSource() instanceof EntityPlayer) && Math.random() < dropRate + lootingBoost * event.getLootingLevel()) event.getDrops().add(new EntityItem(event.getEntity().getEntityWorld(), event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, new ItemStack(witch_hat))); }