當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。