当前位置: 首页>>代码示例>>Java>>正文


Java EntityLivingBase.attackEntityFrom方法代码示例

本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.attackEntityFrom方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.attackEntityFrom方法的具体用法?Java EntityLivingBase.attackEntityFrom怎么用?Java EntityLivingBase.attackEntityFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.EntityLivingBase的用法示例。


在下文中一共展示了EntityLivingBase.attackEntityFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attackEntityFrom

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (!this.func_175472_n() && !source.isMagicDamage() && source.getSourceOfDamage() instanceof EntityLivingBase)
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)source.getSourceOfDamage();

        if (!source.isExplosion())
        {
            entitylivingbase.attackEntityFrom(DamageSource.causeThornsDamage(this), 2.0F);
            entitylivingbase.playSound("damage.thorns", 0.5F, 1.0F);
        }
    }

    this.wander.makeUpdate();
    return super.attackEntityFrom(source, amount);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:EntityGuardian.java

示例2: onExecutionTick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionTick(EntityPlayer player, int progress)
{
	player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 2F);
	Vec3d look = player.getLookVec().scale(3);
	Vec3d pos = player.getPositionVector();
	List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
	EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
	if (assumedToBeLookedAt != null)
	{
		assumedToBeLookedAt.hurtResistantTime = 0;
		assumedToBeLookedAt.attackEntityFrom(DamageSource.causePlayerDamage(player), Math.max(1, (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() / 10));
		player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 0.1F);
		Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
		player.world.spawnParticle(EnumParticleTypes.CRIT, targetPos.x + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, targetPos.y + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, targetPos.z + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, 0, 0, 0);
		if (!player.world.isRemote)
		{
			ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
			is.damageItem(1, player);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:23,代码来源:Stab.java

示例3: activateSkill

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@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;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:22,代码来源:ItemHammer.java

示例4: affectEntity

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void affectEntity(Entity p_180793_1_, Entity p_180793_2_, EntityLivingBase entityLivingBaseIn, int p_180793_4_, double p_180793_5_)
{
    if ((this.id != heal.id || entityLivingBaseIn.isEntityUndead()) && (this.id != harm.id || !entityLivingBaseIn.isEntityUndead()))
    {
        if (this.id == harm.id && !entityLivingBaseIn.isEntityUndead() || this.id == heal.id && entityLivingBaseIn.isEntityUndead())
        {
            int j = (int)(p_180793_5_ * (double)(6 << p_180793_4_) + 0.5D);

            if (p_180793_1_ == null)
            {
                entityLivingBaseIn.attackEntityFrom(DamageSource.magic, (float)j);
            }
            else
            {
                entityLivingBaseIn.attackEntityFrom(DamageSource.causeIndirectMagicDamage(p_180793_1_, p_180793_2_), (float)j);
            }
        }
    }
    else
    {
        int i = (int)(p_180793_5_ * (double)(4 << p_180793_4_) + 0.5D);
        entityLivingBaseIn.heal((float)i);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:Potion.java

示例5: attackEntityFrom

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (!this.isMoving() && !source.isMagicDamage() && source.getSourceOfDamage() instanceof EntityLivingBase)
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)source.getSourceOfDamage();

        if (!source.isExplosion())
        {
            entitylivingbase.attackEntityFrom(DamageSource.causeThornsDamage(this), 2.0F);
        }
    }

    if (this.wander != null)
    {
        this.wander.makeUpdate();
    }

    return super.attackEntityFrom(source, amount);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:EntityGuardian.java

示例6: affectEntity

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void affectEntity(@Nullable Entity source, @Nullable Entity indirectSource, EntityLivingBase entityLivingBaseIn, int amplifier, double health)
{
    if ((this != MobEffects.INSTANT_HEALTH || entityLivingBaseIn.isEntityUndead()) && (this != MobEffects.INSTANT_DAMAGE || !entityLivingBaseIn.isEntityUndead()))
    {
        if (this == MobEffects.INSTANT_DAMAGE && !entityLivingBaseIn.isEntityUndead() || this == MobEffects.INSTANT_HEALTH && entityLivingBaseIn.isEntityUndead())
        {
            int j = (int)(health * (double)(6 << amplifier) + 0.5D);

            if (source == null)
            {
                entityLivingBaseIn.attackEntityFrom(DamageSource.magic, (float)j);
            }
            else
            {
                entityLivingBaseIn.attackEntityFrom(DamageSource.causeIndirectMagicDamage(source, indirectSource), (float)j);
            }
        }
    }
    else
    {
        int i = (int)(health * (double)(4 << amplifier) + 0.5D);
        entityLivingBaseIn.heal((float)i);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:Potion.java

示例7: func_190551_c

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private void func_190551_c(EntityLivingBase p_190551_1_)
{
    EntityLivingBase entitylivingbase = this.func_190552_j();

    if (p_190551_1_.isEntityAlive() && !p_190551_1_.func_190530_aW() && p_190551_1_ != entitylivingbase)
    {
        if (entitylivingbase == null)
        {
            p_190551_1_.attackEntityFrom(DamageSource.magic, 6.0F);
        }
        else
        {
            if (entitylivingbase.isOnSameTeam(p_190551_1_))
            {
                return;
            }

            p_190551_1_.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, entitylivingbase), 6.0F);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:EntityEvokerFangs.java

示例8: hitEntity

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
	if (!target.world.isRemote)
		if (target instanceof EntityEnderman && attacker instanceof EntityPlayer) {
			target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 20);
			stack.damageItem(50, attacker);
		} else {
			stack.damageItem(1, attacker);
		}
	return true;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:12,代码来源:ItemAthame.java

示例9: hitEntity

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, @Nonnull EntityLivingBase attacker) {
	if (!target.world.isRemote) {
		if (target.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD && attacker instanceof EntityPlayer) {
			target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 12);
			stack.damageItem(25, attacker);
		} else {
			stack.damageItem(1, attacker);
		}
	}

	return true;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:14,代码来源:ItemSilverHoe.java

示例10: onExecutionStart

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
	ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
	EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
	player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 1F);
	Vec3d playerLook = player.getLookVec();
	Vec3d playerPos = player.getPositionVector();
	player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0);
	AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3));
	List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player);
	for (EntityLivingBase ent : lst)
	{
		if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player)
		{
			continue;
		}
		
		Vec3d ePos = ent.getPositionVector();
		Vec3d player2ent = ePos.subtract(playerPos).normalize();
		float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook)));
		if (angle > 60)
		{
			continue;
		}
		
		ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.85F));
		player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 2F);
		if (!player.world.isRemote && weight == EnumWeaponWeight.HEAVY && player.world.rand.nextBoolean())
		{
			ent.addPotionEffect(new PotionEffect(ExPPotions.stunned, 100, 0, false, false));
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:35,代码来源:Slash.java

示例11: onUpdate

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onUpdate()
{
    prevPosX = posX;
    prevPosY = posY;
    prevPosZ = posZ;

    moveEntity(motionX, motionY, motionZ);

    AxisAlignedBB range = new AxisAlignedBB(posX - 0.5, posY, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5);
    List<EntityLivingBase> mobsInRange = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, range);

    for (EntityLivingBase target : mobsInRange)
    {
        if (target != caster)
        {
            target.attackEntityFrom(DamageSource.magic, damage);
            this.isCollided = true;
            break;
        }
    }

    if (isCollided)
    {
        this.setExpired();
    }

    if (prevPosY == posY && motionY > 0)
    {
        this.setExpired();
    }

    if (this.particleMaxAge-- <= 0)
    {
        this.setExpired();
    }
}
 
开发者ID:Drazuam,项目名称:RunicArcana,代码行数:38,代码来源:EarthStrikeFX.java

示例12: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.theEntity.getAttackTarget();
    this.theEntity.getNavigator().clearPathEntity();
    this.theEntity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F);

    if (!this.theEntity.canEntityBeSeen(entitylivingbase))
    {
        this.theEntity.setAttackTarget((EntityLivingBase)null);
    }
    else
    {
        ++this.tickCounter;

        if (this.tickCounter == 0)
        {
            this.theEntity.setTargetedEntity(this.theEntity.getAttackTarget().getEntityId());
            this.theEntity.worldObj.setEntityState(this.theEntity, (byte)21);
        }
        else if (this.tickCounter >= this.theEntity.func_175464_ck())
        {
            float f = 1.0F;

            if (this.theEntity.worldObj.getDifficulty() == EnumDifficulty.HARD)
            {
                f += 2.0F;
            }

            if (this.theEntity.isElder())
            {
                f += 2.0F;
            }

            entitylivingbase.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this.theEntity, this.theEntity), f);
            entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(this.theEntity), (float)this.theEntity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue());
            this.theEntity.setAttackTarget((EntityLivingBase)null);
        }
        else if (this.tickCounter >= 60 && this.tickCounter % 20 == 0)
        {
            ;
        }

        super.updateTask();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:46,代码来源:EntityGuardian.java

示例13: func_191510_k

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private void func_191510_k()
{
    float f = 0.0F;
    ItemStack itemstack = (ItemStack)this.dataManager.get(FIREWORK_ITEM);
    NBTTagCompound nbttagcompound = itemstack.func_190926_b() ? null : itemstack.getSubCompound("Fireworks");
    NBTTagList nbttaglist = nbttagcompound != null ? nbttagcompound.getTagList("Explosions", 10) : null;

    if (nbttaglist != null && !nbttaglist.hasNoTags())
    {
        f = (float)(5 + nbttaglist.tagCount() * 2);
    }

    if (f > 0.0F)
    {
        if (this.field_191513_e != null)
        {
            this.field_191513_e.attackEntityFrom(DamageSource.field_191552_t, (float)(5 + nbttaglist.tagCount() * 2));
        }

        double d0 = 5.0D;
        Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);

        for (EntityLivingBase entitylivingbase : this.world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expandXyz(5.0D)))
        {
            if (entitylivingbase != this.field_191513_e && this.getDistanceSqToEntity(entitylivingbase) <= 25.0D)
            {
                boolean flag = false;

                for (int i = 0; i < 2; ++i)
                {
                    RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, new Vec3d(entitylivingbase.posX, entitylivingbase.posY + (double)entitylivingbase.height * 0.5D * (double)i, entitylivingbase.posZ), false, true, false);

                    if (raytraceresult == null || raytraceresult.typeOfHit == RayTraceResult.Type.MISS)
                    {
                        flag = true;
                        break;
                    }
                }

                if (flag)
                {
                    float f1 = f * (float)Math.sqrt((5.0D - (double)this.getDistanceToEntity(entitylivingbase)) / 5.0D);
                    entitylivingbase.attackEntityFrom(DamageSource.field_191552_t, f1);
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:49,代码来源:EntityFireworkRocket.java

示例14: performEffect

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void performEffect(EntityLivingBase entityLivingBaseIn, int p_76394_2_)
{
    if (this.id == regeneration.id)
    {
        if (entityLivingBaseIn.getHealth() < entityLivingBaseIn.getMaxHealth())
        {
            entityLivingBaseIn.heal(1.0F);
        }
    }
    else if (this.id == poison.id)
    {
        if (entityLivingBaseIn.getHealth() > 1.0F)
        {
            entityLivingBaseIn.attackEntityFrom(DamageSource.magic, 1.0F);
        }
    }
    else if (this.id == wither.id)
    {
        entityLivingBaseIn.attackEntityFrom(DamageSource.wither, 1.0F);
    }
    else if (this.id == hunger.id && entityLivingBaseIn instanceof EntityPlayer)
    {
        ((EntityPlayer)entityLivingBaseIn).addExhaustion(0.025F * (float)(p_76394_2_ + 1));
    }
    else if (this.id == saturation.id && entityLivingBaseIn instanceof EntityPlayer)
    {
        if (!entityLivingBaseIn.worldObj.isRemote)
        {
            ((EntityPlayer)entityLivingBaseIn).getFoodStats().addStats(p_76394_2_ + 1, 1.0F);
        }
    }
    else if ((this.id != heal.id || entityLivingBaseIn.isEntityUndead()) && (this.id != harm.id || !entityLivingBaseIn.isEntityUndead()))
    {
        if (this.id == harm.id && !entityLivingBaseIn.isEntityUndead() || this.id == heal.id && entityLivingBaseIn.isEntityUndead())
        {
            entityLivingBaseIn.attackEntityFrom(DamageSource.magic, (float)(6 << p_76394_2_));
        }
    }
    else
    {
        entityLivingBaseIn.heal((float)Math.max(4 << p_76394_2_, 0));
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:44,代码来源:Potion.java

示例15: onFinish

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onFinish(World world, BlockPos pos, EntityLivingBase entity, int amplifier) {
	if (entity instanceof EntityLivingBase) {
		entity.attackEntityFrom(DamageSource.MAGIC, 500000);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:7,代码来源:MortalCoilBrew.java


注:本文中的net.minecraft.entity.EntityLivingBase.attackEntityFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。