Java 类net.minecraft.util.EntityDamageSource 实例源码

项目:Uranium    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:harshencastle    文件:HandlerSoulHarsherSword.java   
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
    try
    {
        if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
                && (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof BaseHarshenSword ||
                    ((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
               &&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
                && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
                && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
                && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
            event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
    }
    catch (ClassCastException clazz){}
}
项目:harshencastle    文件:HandlerRaptorScythe.java   
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
    try
    {
        if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
                && (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof RaptorScythe ||
                    ((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
               &&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
                && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
                && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
                && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
            event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
    }
    catch (ClassCastException clazz){}
}
项目:DecompiledMinecraft    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if (source instanceof EntityDamageSource || source == DamageSource.magic)
        {
            this.summonSilverfish.func_179462_f();
        }

        return super.attackEntityFrom(source, amount);
    }
}
项目:DecompiledMinecraft    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if (source instanceof EntityDamageSource || source == DamageSource.magic)
        {
            this.summonSilverfish.func_179462_f();
        }

        return super.attackEntityFrom(source, amount);
    }
}
项目:BaseClient    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if (source instanceof EntityDamageSource || source == DamageSource.magic)
        {
            this.summonSilverfish.func_179462_f();
        }

        return super.attackEntityFrom(source, amount);
    }
}
项目:BaseClient    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if (source instanceof EntityDamageSource || source == DamageSource.magic)
        {
            this.summonSilverfish.func_179462_f();
        }

        return super.attackEntityFrom(source, amount);
    }
}
项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
    if (!EtFuturum.enableDmgIndicator)
        return;
    int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
    if (amount <= 0)
        return;

    // If the attacker is a player spawn the hearts aligned and facing it
    if (event.source instanceof EntityDamageSource) {
        EntityDamageSource src = (EntityDamageSource) event.source;
        Entity attacker = src.getSourceOfDamage();
        if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
            EntityPlayer player = (EntityPlayer) attacker;
            Vec3 look = player.getLookVec();
            look.rotateAroundY((float) Math.PI / 2);
            for (int i = 0; i < amount; i++) {
                double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
                double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
                double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
                EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
            }
        }
    }
}
项目:Thermionics    文件:ItemHammer.java   
@Override
public int activateSkill(IWeaponSkillInfo info, EntityLivingBase attacker, ItemStack item, DamageSource source, EntityLivingBase opponent) {
    //If you don't know about Earthbound, we can't be friends. Sorry, I don't make the rules.
    DamageSource smaaaaaaash = new EntityDamageSource("weaponskill.smash", attacker);
    opponent.attackEntityFrom(smaaaaaaash, 4f);

    opponent.addPotionEffect( new PotionEffect(Potion.getPotionFromResourceLocation("minecraft:blindness"), 20*3, 2 ));
    //Thermionics.LOG.info("SMAAAAAAASH WeaponSkill activated against entity {} at {},{},{}", opponent, opponent.posX, opponent.posY, opponent.posZ);
    if (opponent instanceof EntityMob) {
        EntityMob monster = (EntityMob)opponent;
        monster.setAttackTarget(null);
        monster.setRevengeTarget(null);
    }
    if (!attacker.world.isRemote) {
        //Serverside, queue the effect
        SpawnParticleEmitterMessage fx = new SpawnParticleEmitterMessage(Thermionics.CONTEXT, EnumWeaponSkill.SMAAAAAAASH, opponent);
        fx.sendToAllWatching(opponent);
    }

    return 20*5;
}
项目:Backmemed    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if ((source instanceof EntityDamageSource || source == DamageSource.magic) && this.summonSilverfish != null)
        {
            this.summonSilverfish.notifyHurt();
        }

        return super.attackEntityFrom(source, amount);
    }
}
项目:CustomWorldGen    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if ((source instanceof EntityDamageSource || source == DamageSource.magic) && this.summonSilverfish != null)
        {
            this.summonSilverfish.notifyHurt();
        }

        return super.attackEntityFrom(source, amount);
    }
}
项目:Aether-Legacy    文件:AetherEventHandler.java   
@SubscribeEvent
public void onEntityDropLoot(LivingDropsEvent event)
{
    if (event.getSource() instanceof EntityDamageSource)
    {
        EntityLivingBase entity = event.getEntityLiving();
        EntityDamageSource source = (EntityDamageSource) event.getSource();

        if (source.getEntity() instanceof EntityPlayer)
        {
            EntityPlayer player = (EntityPlayer) source.getEntity();
            ItemStack currentItem = player.inventory.getCurrentItem();

            if (currentItem != null && currentItem.getItem() instanceof ItemSkyrootSword && !(entity instanceof EntityPlayer) && !(entity instanceof EntityWither))
            {
                for (EntityItem items : event.getDrops())
                {
                    EntityItem item = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, items.getEntityItem());
                    entity.worldObj.spawnEntityInWorld(item);
                }
            }
        }
    }
}
项目:ThermosRebased    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:OpenTechnology    文件:TileEntityCreativeChatBox.java   
public void eventDeath(EntityPlayer player, DamageSource damageSource){
    if(node != null){
        if(damageSource instanceof EntityDamageSource){
            EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
            String damage = "";
            try{
                damage = entityDamageSource.func_151519_b(player).getUnformattedTextForChat();
            }catch (Exception e){
                e.printStackTrace();
            }
            node.sendToReachable("computer.signal", "player_death", player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, getDistanceFrom(player.posX, player.posY, player.posZ), player.getDisplayName(), damageSource.damageType, damage);
        }else{

            node.sendToReachable("computer.signal", "player_death", player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, getDistanceFrom(player.posX, player.posY, player.posZ), player.getDisplayName(), damageSource.damageType, null);
        }
    }
}
项目:TaleCraft    文件:EntityBullet.java   
@Override
protected void onImpact(RayTraceResult result) {
    if (world.isRemote)
        return;
    boolean kill = true;
    if (result.typeOfHit == Type.ENTITY) {
        Entity ent = result.entityHit;
        if (ent instanceof EntityPlayerMP) {
            kill = false;
        } else
            ent.attackEntityFrom(
                    (new EntityDamageSource("arrow", getThrower())).setProjectile(),
                    damage);
    }
    if (result.typeOfHit == Type.BLOCK) {
        if (!world.getBlockState(result.getBlockPos()).isFullBlock()) {
            kill = false;
        }
    }
    if (kill)
        setDead();
}
项目:Thermos    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:KCauldron    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:CauldronGit    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:Cauldron-Old    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:Cauldron-Reloaded    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:FFoKC    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:Wars-Mod    文件:CommonEvents.java   
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent evt) {
    if (evt.getEntity() instanceof EntityPlayer && evt.getSource() instanceof EntityDamageSource) {
        EntityDamageSource source = (EntityDamageSource) evt.getSource();
        if (source.getEntity() instanceof EntityPlayer) {
            EntityPlayer attacker = (EntityPlayer) source.getEntity();
            EntityPlayer damagee = (EntityPlayer) evt.getEntity();

            ItemStack attackerBoots = attacker.inventory.armorItemInSlot(0);
            ItemStack damageeBoots = damagee.inventory.armorItemInSlot(0);
            if (attackerBoots != null && damageeBoots != null && attackerBoots == damageeBoots) {
                Item id = damageeBoots.getItem();
                if (id == WarsItems.redBoots || id == WarsItems.greenBoots || id == WarsItems.blueBoots || id == WarsItems.yellowBoots) {
                    evt.setCanceled(true);
                }
            }
        }
    }
}
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
    if (!EtFuturum.enableDmgIndicator)
        return;
    int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
    if (amount <= 0)
        return;

    // If the attacker is a player spawn the hearts aligned and facing it
    if (event.source instanceof EntityDamageSource) {
        EntityDamageSource src = (EntityDamageSource) event.source;
        Entity attacker = src.getSourceOfDamage();
        if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
            EntityPlayer player = (EntityPlayer) attacker;
            Vec3 look = player.getLookVec();
            look.rotateAroundY((float) Math.PI / 2);
            for (int i = 0; i < amount; i++) {
                double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
                double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
                double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
                EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
            }
        }
    }
}
项目:Resilience-Client-Source    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else
    {
        if (this.allySummonCooldown <= 0 && (par1DamageSource instanceof EntityDamageSource || par1DamageSource == DamageSource.magic))
        {
            this.allySummonCooldown = 20;
        }

        return super.attackEntityFrom(par1DamageSource, par2);
    }
}
项目:BluePower    文件:BPEventHandler.java   
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
    if(event.source instanceof EntityDamageSource) {
        EntityDamageSource entitySource = (EntityDamageSource) event.source;

        if(entitySource.getEntity() instanceof EntityPlayer) {
            EntityPlayer killer = (EntityPlayer) entitySource.getEntity();

            if(killer.inventory.getCurrentItem() != null) { 
                if(EnchantmentHelper.getEnchantments(killer.inventory.getCurrentItem()).containsKey(BPEnchantments.vorpal.effectId)) {
                    int level = EnchantmentHelper.getEnchantmentLevel(BPEnchantments.vorpal.effectId, killer.inventory.getCurrentItem());

                    if(level == 1) {
                        if(killer.worldObj.rand.nextInt(6) == 1) {
                            this.dropHeads(event);
                        }
                    } else if(level == 2) {
                        if(killer.worldObj.rand.nextInt(3) == 1) {
                        this.dropHeads(event);
                        }
                    }
                }
            }
        }
    }
}
项目:sprinkles_for_vanilla    文件:EntityHandlers.java   
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
    DamageSource source = event.source;
    if (source.damageType == "player" && SprinklesForVanilla.isOnServer && event.ammount > 0)
    {
        EntityPlayer player = (EntityPlayer)((EntityDamageSource)source).getEntity();
        if (player != null)
        {
            ItemStack heldItem = player.getCurrentEquippedItem();
            if (heldItem != null)
            {
                Multimap attribMap = heldItem.getAttributeModifiers();
                //If held item doesn't change the base damage
                if (!attribMap.containsKey(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()))
                {
                    event.ammount *= Settings.playerPunchDamageMultiplier[1];
                }
            }
            else
            {
                event.ammount *= Settings.playerPunchDamageMultiplier[1];
            }
        }
    }
}
项目:ExpandedRailsMod    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if ((source instanceof EntityDamageSource || source == DamageSource.magic) && this.summonSilverfish != null)
        {
            this.summonSilverfish.notifyHurt();
        }

        return super.attackEntityFrom(source, amount);
    }
}
项目:MoarPeripherals    文件:TileChatBox.java   
@Override
public void onDeathEvent(LivingDeathEvent event) {
    if (event.entity instanceof EntityPlayerMP) {
        DamageSource source = event.source;
        String killer = null;
        if (source instanceof EntityDamageSource) {
            Entity ent = source.getEntity();
            if (ent != null) {
                killer = ent.getCommandSenderName();
            }
        }
        if (rangeRead < 0 || entityInRange(event.entity, rangeRead)) {
            computerQueueEvent(EVENT_DEATH, event.entity.getCommandSenderName(), source.getDamageType(), killer);
        }
    }
}
项目:Cauldron    文件:EntitySilverfish.java   
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else
    {
        if (this.allySummonCooldown <= 0 && (p_70097_1_ instanceof EntityDamageSource || p_70097_1_ == DamageSource.magic))
        {
            this.allySummonCooldown = 20;
        }

        return super.attackEntityFrom(p_70097_1_, p_70097_2_);
    }
}
项目:Cauldron    文件:EntitySilverfish.java   
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else
    {
        if (this.allySummonCooldown <= 0 && (p_70097_1_ instanceof EntityDamageSource || p_70097_1_ == DamageSource.magic))
        {
            this.allySummonCooldown = 20;
        }

        return super.attackEntityFrom(p_70097_1_, p_70097_2_);
    }
}
项目:Cauldron    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
项目:RuneCraftery    文件:EntityPlayerMP.java   
public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) {
   if(this.func_85032_ar()) {
      return false;
   } else {
      boolean var3 = this.field_71133_b.func_71262_S() && this.field_71133_b.func_71219_W() && "fall".equals(p_70097_1_.field_76373_n);
      if(!var3 && this.field_71145_cl > 0 && p_70097_1_ != DamageSource.field_76380_i) {
         return false;
      } else {
         if(p_70097_1_ instanceof EntityDamageSource) {
            Entity var4 = p_70097_1_.func_76346_g();
            if(var4 instanceof EntityPlayer && !this.func_96122_a((EntityPlayer)var4)) {
               return false;
            }

            if(var4 instanceof EntityArrow) {
               EntityArrow var5 = (EntityArrow)var4;
               if(var5.field_70250_c instanceof EntityPlayer && !this.func_96122_a((EntityPlayer)var5.field_70250_c)) {
                  return false;
               }
            }
         }

         return super.func_70097_a(p_70097_1_, p_70097_2_);
      }
   }
}
项目:RuneCraftery    文件:EntityEnderman.java   
public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) {
   if(this.func_85032_ar()) {
      return false;
   } else {
      this.func_70819_e(true);
      if(p_70097_1_ instanceof EntityDamageSource && p_70097_1_.func_76346_g() instanceof EntityPlayer) {
         this.field_104003_g = true;
      }

      if(p_70097_1_ instanceof EntityDamageSourceIndirect) {
         this.field_104003_g = false;

         for(int var3 = 0; var3 < 64; ++var3) {
            if(this.func_70820_n()) {
               return true;
            }
         }

         return false;
      } else {
         return super.func_70097_a(p_70097_1_, p_70097_2_);
      }
   }
}
项目:RuneCraftery    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else
    {
        if (this.allySummonCooldown <= 0 && (par1DamageSource instanceof EntityDamageSource || par1DamageSource == DamageSource.magic))
        {
            this.allySummonCooldown = 20;
        }

        return super.attackEntityFrom(par1DamageSource, par2);
    }
}
项目:IceAndShadow2    文件:EntityNyxWightSanctified.java   
/**
 * Called when the entity is attacked.
 */
@Override
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
    if (isEntityInvulnerable() || !par1DamageSource.isUnblockable() || par1DamageSource == DamageSource.drown
            || par1DamageSource == DamageSource.wither)
        return false;
    boolean flag;
    if (par1DamageSource.isMagicDamage() && !par1DamageSource.isDamageAbsolute()) {
        par2 -= IaSWorldHelper.getRegionArmorMod(this);
    }
    if (par1DamageSource.isDamageAbsolute() && !isInvisible()) {
        flag = super.attackEntityFrom(par1DamageSource, par2);
    } else {
        flag = super.attackEntityFrom(par1DamageSource, par2 / 2);
    }
    if (par1DamageSource instanceof EntityDamageSource && !par1DamageSource.isProjectile()
            && !par1DamageSource.isMagicDamage() && !par1DamageSource.isExplosion()
            && !par1DamageSource.isFireDamage()) {
        final Entity ent = ((EntityDamageSource) par1DamageSource).getEntity();
        if (ent instanceof EntityPlayer) {
            ((EntityPlayer) ent).dropOneItem(false);
        }
    }
    return flag;
}
项目:Mini-Bosses    文件:EntityForestGuard.java   
@Override
public boolean attackEntityFrom(DamageSource source, float damage) {
    super.attackEntityFrom(source, damage);
    if(source instanceof EntityDamageSource) {
        this.getDataWatcher().updateObject(13, Integer.valueOf(1));
    }
    if(this.rand.nextInt(9) == 1 && source.getEntity() != null) {
        this.setPosition(source.getEntity().posX, source.getEntity().posY, source.getEntity().posZ - 2);
    }
    if(this.rand.nextInt(19) == 1) {
        if(FMLCommonHandler.instance().getSide() == Side.SERVER) {
            for(int i = 0; i < MathHelper.getRandomIntegerInRange(rand, 3, 5); i++) {
                //System.out.println("SHOULD SPAWN");
                EntitySprout sprout = new EntitySprout(this.worldObj);

                sprout.setPosition(this.posX, this.posY, this.posZ);
                this.worldObj.spawnEntityInWorld(sprout);
            }
        }
    }
    return true;
}
项目:BetterNutritionMod    文件:EntitySilverfish.java   
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else
    {
        if (this.allySummonCooldown <= 0 && (par1DamageSource instanceof EntityDamageSource || par1DamageSource == DamageSource.magic))
        {
            this.allySummonCooldown = 20;
        }

        return super.attackEntityFrom(par1DamageSource, par2);
    }
}
项目:Bewitchment    文件:SpellPoke.java   
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
    if (rtrace.typeOfHit == Type.ENTITY && rtrace.entityHit instanceof EntityLivingBase) {
        if (caster != null)
            rtrace.entityHit.attackEntityFrom(new EntityDamageSource(DamageSource.MAGIC.getDamageType(), caster), 1f);
        else rtrace.entityHit.attackEntityFrom(DamageSource.MAGIC, 0.5f);
    }
}
项目:harshencastle    文件:HandlerGlassContainer.java   
@SubscribeEvent
public void onEntityHit(LivingHurtEvent event)
{
    if(event.getSource() instanceof EntityDamageSource && ((EntityDamageSource) event.getSource()).getTrueSource() instanceof EntityLivingBase && 
            ((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof GlassContainer && 
            ((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand().getItemDamage() == 0)
    {
        ItemStack stack = ((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand();
        stack.setItemDamage(2);
        ((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).setHeldItem(EnumHand.MAIN_HAND, stack);
    }       
}
项目:harshencastle    文件:HandlerBloodOnHurt.java   
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
    if(new Random().nextDouble() < GeneralConfig.bloodChance && event.getSource() instanceof EntityDamageSource && HarshenUtils.toArray(AllowedEntities).contains(event.getEntity().getClass()))
        if(event.getEntity().world.isAirBlock(event.getEntity().getPosition()) && GeneralConfig.bloodDrops)
            event.getEntity().getEntityWorld().setBlockState(event.getEntity().getPosition(), HarshenBlocks.BLOOD_BLOCK.getDefaultState(), 3);
        else if(event.getSource().getTrueSource() instanceof EntityPlayer && GeneralConfig.bloodOffHand &&
                ((EntityPlayer)event.getSource().getTrueSource()).getHeldItemOffhand().getItem() == HarshenItems.BLOOD_COLLECTOR)
            ((BloodCollector)((EntityPlayer)event.getSource().getTrueSource()).getHeldItemOffhand().getItem()).fill(((EntityPlayer)event.getSource().getTrueSource()), EnumHand.OFF_HAND, 1);
}