@SubscribeEvent public static void onPlayerAttacked(LivingAttackEvent event) { if(event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); if(getOdinRing(player) != null && damageNegations.contains(event.getSource().damageType)) event.setCanceled(true); } }
return; if(!shouldBlockDamage(event.getEntityLiving())) { return; EntityPlayer player = (EntityPlayer) event.getEntityLiving(); ItemStack battlesign = player.getActiveItemStack();
@SubscribeEvent public void onEntityAttack(LivingAttackEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) { MOPlayerCapabilityProvider.GetAndroidCapability(event.getEntityLiving()).triggerEventOnStats(event); } }
@SubscribeEvent public void onDamage(LivingAttackEvent event) { if (event.getSource() == DamageSource.starve && event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = ((EntityPlayer)event.getEntityLiving()); if (player.isPlayerSleeping()) { event.setCanceled(true); } } }
@SubscribeEvent public void onEntityMounted(LivingAttackEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) { /* if (event.entityLiving.ridingEntity != null && event.entityLiving.ridingEntity instanceof EntityArmchairMount) if(event.entityLiving.ridingEntity.worldObj.isAirBlock((int) (event.entityLiving.ridingEntity.posX - 0.5D), (int)(event.entityLiving.ridingEntity.posY + 1D), (int)(event.entityLiving.ridingEntity.posZ - 0.5D))) if(event.entityLiving.ridingEntity.worldObj.isAirBlock((int) (event.entityLiving.ridingEntity.posX - 0.5D), (int)(event.entityLiving.ridingEntity.posY + 2D), (int)(event.entityLiving.ridingEntity.posZ - 0.5D))) if (event.source == DamageSource.inWall) event.setCanceled(true); */ if (event.getEntityLiving().getRidingEntity() != null && event.getEntityLiving().getRidingEntity() instanceof EntityLivingBase) if (event.getSource() == DamageSource.IN_WALL) event.setCanceled(true); } } }
@SubscribeEvent public void onEntityAttacked(LivingAttackEvent event) { AnimalStats stats = EntityHelper.getStats(event.getEntityLiving()); if (stats != null) { event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 200, 0, true, false)); } }
@SubscribeEvent public void entityAttackedEvent(LivingAttackEvent event) { EntityLivingBase entity = event.getEntityLiving(); int fakeDrops = OMTUtil.getFakeDropsLevel(entity); if (fakeDrops >= 0) { FakePlayer player = OMTFakePlayer.getFakePlayer((WorldServer) event.getEntityLiving().getEntityWorld()); player.setHeldItem(EnumHand.MAIN_HAND, OMTFakePlayer.getSword(fakeDrops)); entity.setLastAttackedEntity(player); } }
@SubscribeEvent public void onLivingAttacked(LivingAttackEvent event) { if(event.getSource().getTrueSource() != null){ Entity attacker = event.getSource().getTrueSource(); if (isAnimaniaChicken(event.getEntityLiving()) && attacker instanceof EntityLivingBase) { signalChickenAlarm(event.getEntityLiving(), (EntityLivingBase) attacker); } } }
@SubscribeEvent(priority = EventPriority.HIGHEST) public static void onPlayerDamageEvent(LivingAttackEvent event) { if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.WHIRLWIND) && event.isCancelable() && event.getSource().isProjectile()) event.setCanceled(true); }
@SubscribeEvent public void onAttack(LivingAttackEvent event){ if(event.getEntityLiving() instanceof EntityPlayer && ((EntityPlayer) event.getEntityLiving()).capabilities.isCreativeMode) EntityLivingBase entityHit = event.getEntityLiving();
@SubscribeEvent public void onEntityAttacked(LivingAttackEvent event) { //Probably not a very "clean" solution, but the only one I found if (!skipAttackDamageOnce && "player".equals(event.getSource().getDamageType()) && event.getSource().getTrueSource() instanceof EntityPlayer) { ItemStack stack = ((EntityPlayer) event.getSource().getTrueSource()).getHeldItemMainhand(); if (!stack.isEmpty() && stack.getItem() instanceof IFactionSlayerItem) { IFactionSlayerItem item = (IFactionSlayerItem) stack.getItem(); IFaction faction = VampirismAPI.factionRegistry().getFaction(event.getEntity()); if (faction != null && faction.equals(item.getSlayedFaction())) { float amt = event.getAmount() * item.getDamageMultiplierForFaction(stack); skipAttackDamageOnce = true; boolean result = net.minecraftforge.common.ForgeHooks.onLivingAttack(event.getEntityLiving(), event.getSource(), amt); skipAttackDamageOnce = false; event.setCanceled(!result); } } } }
@SubscribeEvent (priority = EventPriority.HIGH) public void handleLivingAttackEvent(LivingAttackEvent event) { Entity entity = event.getEntity(); if (!(entity instanceof EntityPlayer)) { return; } DamageSource source = event.getSource(); if (source instanceof EntityDamageSourceIndirect || source.isUnblockable() || source.isProjectile()) { return; } if (source instanceof EntityDamageSource && ((EntityDamageSource) source).getIsThornsDamage()) { return; } EntityPlayer player = (EntityPlayer) event.getEntityLiving(); ItemStack stack = player.getActiveItemStack(); if (!stack.isEmpty() && stack.getItem() instanceof ItemShieldCore) { ((ItemShieldCore) stack.getItem()).onHit(stack, player, source.getTrueSource()); } }
@SubscribeEvent public void onEntityDamage(LivingAttackEvent event) { if (!ModConfig.general.cowJarEnabled) { return; } if (event.getSource() == DamageSource.ANVIL && isCow(event.getEntityLiving())) { BlockPos pos = event.getEntity().getPosition().down(); IBlockState blockBelow = event.getEntity().getEntityWorld().getBlockState(pos); if (blockBelow.getBlock() == ModBlocks.milkJar) { event.getEntity().getEntityWorld().setBlockState(pos, ModBlocks.cowJar.getDefaultState()); } NetworkHandler.instance.sendToAllAround(new MessageSyncedEffect(pos, MessageSyncedEffect.Type.COW_IN_A_JAR), new NetworkRegistry.TargetPoint(event.getEntity().world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 32)); event.getEntity().setDead(); event.setCanceled(true); } }