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


Java DamageSource类代码示例

本文整理汇总了Java中net.minecraft.util.DamageSource的典型用法代码示例。如果您正苦于以下问题:Java DamageSource类的具体用法?Java DamageSource怎么用?Java DamageSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: applyPotionDamageCalculations

import net.minecraft.util.DamageSource; //导入依赖的package包/类
/**
 * Reduces damage, depending on potions
 */
protected float applyPotionDamageCalculations(DamageSource source, float damage)
{
    damage = super.applyPotionDamageCalculations(source, damage);

    if (source.getEntity() == this)
    {
        damage = 0.0F;
    }

    if (source.isMagicDamage())
    {
        damage = (float)((double)damage * 0.15D);
    }

    return damage;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:EntityWitch.java

示例2: attackEntityFrom

import net.minecraft.util.DamageSource; //导入依赖的package包/类
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
	Entity entity = source.getTrueSource();
	boolean takenDamage = super.attackEntityFrom(source, amount);

	if (takenDamage && entity != null)
	{
		this.playSound(ModSoundEvents.ENTITY_FAKE_FADE, 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.1F) + 1.0F);
		this.spawnExplosionParticle();
		this.spawnExplosionParticle(); // TODO - examine why this is being fired twice - twice as many particles?
		this.setDead();
	}

	return takenDamage;
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:17,代码来源:EntityFakeHusk.java

示例3: attackEntityFrom

import net.minecraft.util.DamageSource; //导入依赖的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:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:EntityGuardian.java

示例4: attackEntityFrom

import net.minecraft.util.DamageSource; //导入依赖的package包/类
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        this.setBeenAttacked();
        this.xpOrbHealth = (int)((float)this.xpOrbHealth - amount);

        if (this.xpOrbHealth <= 0)
        {
            this.setDead();
        }

        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:EntityXPOrb.java

示例5: attackEntityFrom

import net.minecraft.util.DamageSource; //导入依赖的package包/类
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    Entity entity = source.getSourceOfDamage();

    if (entity instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entity;

        if (entityarrow.isBurning())
        {
            this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ);
        }
    }

    return super.attackEntityFrom(source, amount);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:EntityMinecartTNT.java

示例6: onDeath

import net.minecraft.util.DamageSource; //导入依赖的package包/类
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getEntity() instanceof EntityCreeper)
    {
        EntityCreeper entitycreeper = (EntityCreeper)cause.getEntity();

        if (entitycreeper.getPowered() && entitycreeper.isAIEnabled())
        {
            entitycreeper.incrementDroppedSkulls();
            this.entityDropItem(new ItemStack(Items.SKULL, 1, 1), 0.0F);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:EntityWitherSkeleton.java

示例7: fall

import net.minecraft.util.DamageSource; //导入依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
    super.fall(distance, damageMultiplier);
    PotionEffect potioneffect = this.getActivePotionEffect(Potion.jump);
    float f = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F;
    int i = MathHelper.ceiling_float_int((distance - 3.0F - f) * damageMultiplier);

    if (i > 0)
    {
        this.playSound(this.getFallSoundString(i), 1.0F, 1.0F);
        this.attackEntityFrom(DamageSource.fall, (float)i);
        int j = MathHelper.floor_double(this.posX);
        int k = MathHelper.floor_double(this.posY - 0.20000000298023224D);
        int l = MathHelper.floor_double(this.posZ);
        Block block = this.worldObj.getBlockState(new BlockPos(j, k, l)).getBlock();

        if (block.getMaterial() != Material.air)
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.playSound(block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:EntityLivingBase.java

示例8: affectEntity

import net.minecraft.util.DamageSource; //导入依赖的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

示例9: updateAITasks

import net.minecraft.util.DamageSource; //导入依赖的package包/类
protected void updateAITasks()
{
    if (this.isWet())
    {
        this.attackEntityFrom(DamageSource.drown, 1.0F);
    }

    if (this.world.isDaytime() && this.ticksExisted >= this.targetChangeTime + 600)
    {
        float f = this.getBrightness(1.0F);

        if (f > 0.5F && this.world.canSeeSky(new BlockPos(this)) && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F)
        {
            this.setAttackTarget((EntityLivingBase)null);
            this.teleportRandomly();
        }
    }

    super.updateAITasks();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:EntityEnderman.java

示例10: updateAITasks

import net.minecraft.util.DamageSource; //导入依赖的package包/类
protected void updateAITasks()
{
    if (this.isWet())
    {
        this.attackEntityFrom(DamageSource.drown, 1.0F);
    }

    --this.heightOffsetUpdateTime;

    if (this.heightOffsetUpdateTime <= 0)
    {
        this.heightOffsetUpdateTime = 100;
        this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F;
    }

    EntityLivingBase entitylivingbase = this.getAttackTarget();

    if (entitylivingbase != null && entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() > this.posY + (double)this.getEyeHeight() + (double)this.heightOffset)
    {
        this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D;
        this.isAirBorne = true;
    }

    super.updateAITasks();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:EntityBlaze.java

示例11: attackEntityFrom

import net.minecraft.util.DamageSource; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:EntitySilverfish.java

示例12: killMinecart

import net.minecraft.util.DamageSource; //导入依赖的package包/类
public void killMinecart(DamageSource source)
{
    this.setDead();

    if (this.world.getGameRules().getBoolean("doEntityDrops"))
    {
        ItemStack itemstack = new ItemStack(Items.MINECART, 1);

        if (this.hasCustomName())
        {
            itemstack.setStackDisplayName(this.getCustomNameTag());
        }

        this.entityDropItem(itemstack, 0.0F);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:EntityMinecart.java

示例13: attackEntityFromPart

import net.minecraft.util.DamageSource; //导入依赖的package包/类
public boolean attackEntityFromPart(EntityDragonPart dragonPart, DamageSource source, float p_70965_3_)
{
    if (dragonPart != this.dragonPartHead)
    {
        p_70965_3_ = p_70965_3_ / 4.0F + 1.0F;
    }

    float f = this.rotationYaw * (float)Math.PI / 180.0F;
    float f1 = MathHelper.sin(f);
    float f2 = MathHelper.cos(f);
    this.targetX = this.posX + (double)(f1 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F);
    this.targetY = this.posY + (double)(this.rand.nextFloat() * 3.0F) + 1.0D;
    this.targetZ = this.posZ - (double)(f2 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F);
    this.target = null;

    if (source.getEntity() instanceof EntityPlayer || source.isExplosion())
    {
        this.attackDragonFrom(source, p_70965_3_);
    }

    return true;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:23,代码来源:EntityDragon.java

示例14: onDeath

import net.minecraft.util.DamageSource; //导入依赖的package包/类
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getEntity() instanceof EntitySkeleton)
    {
        int i = Item.getIdFromItem(Items.record_13);
        int j = Item.getIdFromItem(Items.record_wait);
        int k = i + this.rand.nextInt(j - i + 1);
        this.dropItem(Item.getItemById(k), 1);
    }
    else if (cause.getEntity() instanceof EntityCreeper && cause.getEntity() != this && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
    {
        ((EntityCreeper)cause.getEntity()).func_175493_co();
        this.entityDropItem(new ItemStack(Items.skull, 1, 4), 0.0F);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:EntityCreeper.java

示例15: onDeath

import net.minecraft.util.DamageSource; //导入依赖的package包/类
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
        double d0 = entityplayer.posX - this.posX;
        double d1 = entityplayer.posZ - this.posZ;

        if (d0 * d0 + d1 * d1 >= 2500.0D)
        {
            entityplayer.triggerAchievement(AchievementList.snipeSkeleton);
        }
    }
    else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
    {
        ((EntityCreeper)cause.getEntity()).func_175493_co();
        this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:25,代码来源:EntitySkeleton.java


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