Java Code Examples for net.minecraft.util.DamageSource

The following are top voted examples for showing how to use net.minecraft.util.DamageSource. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: DecompiledMinecraft   File: EntityWitch.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Project: Halloween   File: EntityFakeHusk.java   View source code 6 votes vote down vote up
@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;
}
 
Example 3
Project: BaseClient   File: EntityGuardian.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 4
Project: DecompiledMinecraft   File: EntityXPOrb.java   View source code 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 5
Project: BaseClient   File: EntityMinecartTNT.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 6
Project: Backmemed   File: EntityWitherSkeleton.java   View source code 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 7
Project: BaseClient   File: EntityLivingBase.java   View source code 6 votes vote down vote up
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);
        }
    }
}
 
Example 8
Project: CustomWorldGen   File: Potion.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 9
Project: BaseClient   File: EntityLivingBase.java   View source code 6 votes vote down vote up
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);
        }
    }
}
 
Example 10
Project: Backmemed   File: EntityEnderman.java   View source code 6 votes vote down vote up
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();
}
 
Example 11
Project: Halloween   File: EntityFakeCreeper.java   View source code 6 votes vote down vote up
@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;
}
 
Example 12
Project: BaseClient   File: EntityBlaze.java   View source code 6 votes vote down vote up
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();
}
 
Example 13
Project: BaseClient   File: EntitySilverfish.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 14
Project: Backmemed   File: EntityMinecart.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 15
Project: Backmemed   File: EntityWitch.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 16
Project: BaseClient   File: EntityDragon.java   View source code 6 votes vote down vote up
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;
}
 
Example 17
Project: BaseClient   File: EntityCreeper.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 18
Project: BaseClient   File: EntitySkeleton.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 19
Project: DecompiledMinecraft   File: EntityMob.java   View source code 6 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else if (super.attackEntityFrom(source, amount))
    {
        Entity entity = source.getEntity();
        return this.riddenByEntity != entity && this.ridingEntity != entity ? true : true;
    }
    else
    {
        return false;
    }
}
 
Example 20
Project: DecompiledMinecraft   File: EntityBlaze.java   View source code 6 votes vote down vote up
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();
}
 
Example 21
Project: DecompiledMinecraft   File: EntityMinecartTNT.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 22
Project: Backmemed   File: AbstractHorse.java   View source code 6 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (!this.world.isRemote && this.horseChest != null)
    {
        for (int i = 0; i < this.horseChest.getSizeInventory(); ++i)
        {
            ItemStack itemstack = this.horseChest.getStackInSlot(i);

            if (!itemstack.func_190926_b())
            {
                this.entityDropItem(itemstack, 0.0F);
            }
        }
    }
}
 
Example 23
Project: Backmemed   File: AbstractChestHorse.java   View source code 5 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (this.func_190695_dh())
    {
        if (!this.world.isRemote)
        {
            this.dropItem(Item.getItemFromBlock(Blocks.CHEST), 1);
        }

        this.setChested(false);
    }
}
 
Example 24
Project: Backmemed   File: EntityMinecartFurnace.java   View source code 5 votes vote down vote up
public void killMinecart(DamageSource source)
{
    super.killMinecart(source);

    if (!source.isExplosion() && this.world.getGameRules().getBoolean("doEntityDrops"))
    {
        this.entityDropItem(new ItemStack(Blocks.FURNACE, 1), 0.0F);
    }
}
 
Example 25
Project: CustomWorldGen   File: EntityWolf.java   View source code 5 votes vote down vote up
public boolean attackEntityAsMob(Entity entityIn)
{
    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()));

    if (flag)
    {
        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
Example 26
Project: DecompiledMinecraft   File: EntitySnowman.java   View source code 5 votes vote down vote up
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    super.onLivingUpdate();

    if (!this.worldObj.isRemote)
    {
        int i = MathHelper.floor_double(this.posX);
        int j = MathHelper.floor_double(this.posY);
        int k = MathHelper.floor_double(this.posZ);

        if (this.isWet())
        {
            this.attackEntityFrom(DamageSource.drown, 1.0F);
        }

        if (this.worldObj.getBiomeGenForCoords(new BlockPos(i, 0, k)).getFloatTemperature(new BlockPos(i, j, k)) > 1.0F)
        {
            this.attackEntityFrom(DamageSource.onFire, 1.0F);
        }

        for (int l = 0; l < 4; ++l)
        {
            i = MathHelper.floor_double(this.posX + (double)((float)(l % 2 * 2 - 1) * 0.25F));
            j = MathHelper.floor_double(this.posY);
            k = MathHelper.floor_double(this.posZ + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F));
            BlockPos blockpos = new BlockPos(i, j, k);

            if (this.worldObj.getBlockState(blockpos).getBlock().getMaterial() == Material.air && this.worldObj.getBiomeGenForCoords(new BlockPos(i, 0, k)).getFloatTemperature(blockpos) < 0.8F && Blocks.snow_layer.canPlaceBlockAt(this.worldObj, blockpos))
            {
                this.worldObj.setBlockState(blockpos, Blocks.snow_layer.getDefaultState());
            }
        }
    }
}
 
Example 27
Project: CustomWorldGen   File: EntityLivingBase.java   View source code 5 votes vote down vote up
/**
 * Reduces damage, depending on potions
 */
protected float applyPotionDamageCalculations(DamageSource source, float damage)
{
    if (source.isDamageAbsolute())
    {
        return damage;
    }
    else
    {
        if (this.isPotionActive(MobEffects.RESISTANCE) && source != DamageSource.outOfWorld)
        {
            int i = (this.getActivePotionEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
            int j = 25 - i;
            float f = damage * (float)j;
            damage = f / 25.0F;
        }

        if (damage <= 0.0F)
        {
            return 0.0F;
        }
        else
        {
            int k = EnchantmentHelper.getEnchantmentModifierDamage(this.getArmorInventoryList(), source);

            if (k > 0)
            {
                damage = CombatRules.getDamageAfterMagicAbsorb(damage, (float)k);
            }

            return damage;
        }
    }
}
 
Example 28
Project: BaseClient   File: Entity.java   View source code 5 votes vote down vote up
/**
 * Called when a lightning bolt hits the entity.
 */
public void onStruckByLightning(EntityLightningBolt lightningBolt)
{
    this.attackEntityFrom(DamageSource.lightningBolt, 5.0F);
    ++this.fire;

    if (this.fire == 0)
    {
        this.setFire(8);
    }
}
 
Example 29
Project: Industrial-Foregoing   File: LavaStrawHandler.java   View source code 5 votes vote down vote up
@Override
public void onDrink(World world, BlockPos pos, FluidStack stack, EntityPlayer player, boolean fromFluidContainer) {
    player.attackEntityFrom(DamageSource.LAVA, 7);
    player.setFire(30);
    NBTTagCompound tag = player.getEntityData();
    tag.setLong("lavaDrink", world.getTotalWorldTime());
}
 
Example 30
Project: PurificatiMagicae   File: EntityBeetle.java   View source code 5 votes vote down vote up
@Override
public boolean attackEntityAsMob(Entity entityIn)
{
    if (entityIn instanceof EntityLivingBase)
    {
        ((EntityLivingBase) entityIn).addPotionEffect(new PotionEffect(MobEffects.POISON, 100, 1));
    }
    return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float) getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue());
}
 
Example 31
Project: DecompiledMinecraft   File: EntityHorse.java   View source code 5 votes vote down vote up
public void fall(float distance, float damageMultiplier)
{
    if (distance > 1.0F)
    {
        this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int((distance * 0.5F - 3.0F) * damageMultiplier);

    if (i > 0)
    {
        this.attackEntityFrom(DamageSource.fall, (float)i);

        if (this.riddenByEntity != null)
        {
            this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i);
        }

        Block block = this.worldObj.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ)).getBlock();

        if (block.getMaterial() != Material.air && !this.isSilent())
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.worldObj.playSoundAtEntity(this, block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
Example 32
Project: Mods   File: EntityStatue.java   View source code 5 votes vote down vote up
public boolean attackEntityFrom(DamageSource source, float amount)
  {
      if (this.isEntityInvulnerable(source))
      {
          return false;
      }
      if (source.damageType.equals("player")) {
      	if(this.data != null)
      		this.entityDropItem(ItemStatue.getStatue(this), 0);
      	this.setDead();
      	return true;
      }
return false;
  }
 
Example 33
Project: Bewitchment   File: ItemAthame.java   View source code 5 votes vote down vote up
@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;
}
 
Example 34
Project: Backmemed   File: BlockMagma.java   View source code 5 votes vote down vote up
/**
 * Triggered whenever an entity collides with this block (enters into the block)
 */
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
{
    if (!entityIn.isImmuneToFire() && entityIn instanceof EntityLivingBase && !EnchantmentHelper.hasFrostWalkerEnchantment((EntityLivingBase)entityIn))
    {
        entityIn.attackEntityFrom(DamageSource.hotFloor, 1.0F);
    }

    super.onEntityWalk(worldIn, pos, entityIn);
}
 
Example 35
Project: DecompiledMinecraft   File: EntitySlime.java   View source code 5 votes vote down vote up
protected void func_175451_e(EntityLivingBase p_175451_1_)
{
    int i = this.getSlimeSize();

    if (this.canEntityBeSeen(p_175451_1_) && this.getDistanceSqToEntity(p_175451_1_) < 0.6D * (double)i * 0.6D * (double)i && p_175451_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float)this.getAttackStrength()))
    {
        this.playSound("mob.attack", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        this.applyEnchantments(this, p_175451_1_);
    }
}
 
Example 36
Project: UniversalRemote   File: EntityPlayerProxy.java   View source code 5 votes vote down vote up
@Override
public DamageSource getLastDamageSource() {
	if (m_realPlayer == null) {
		return super.getLastDamageSource();
	} else {
		return m_realPlayer.getLastDamageSource();
	}
}
 
Example 37
Project: Backmemed   File: EntityLivingBase.java   View source code 5 votes vote down vote up
protected void collideWithNearbyEntities()
{
    List<Entity> list = this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox(), EntitySelectors.<Entity>getTeamCollisionPredicate(this));

    if (!list.isEmpty())
    {
        int i = this.world.getGameRules().getInt("maxEntityCramming");

        if (i > 0 && list.size() > i - 1 && this.rand.nextInt(4) == 0)
        {
            int j = 0;

            for (int k = 0; k < list.size(); ++k)
            {
                if (!((Entity)list.get(k)).isRiding())
                {
                    ++j;
                }
            }

            if (j > i - 1)
            {
                this.attackEntityFrom(DamageSource.field_191291_g, 6.0F);
            }
        }

        for (int l = 0; l < list.size(); ++l)
        {
            Entity entity = (Entity)list.get(l);
            this.collideWithEntity(entity);
        }
    }
}
 
Example 38
Project: BaseClient   File: Entity.java   View source code 5 votes vote down vote up
/**
 * Will deal the specified amount of damage to the entity if the entity isn't immune to fire damage. Args:
 * amountDamage
 */
protected void dealFireDamage(int amount)
{
    if (!this.isImmuneToFire)
    {
        this.attackEntityFrom(DamageSource.inFire, (float)amount);
    }
}
 
Example 39
Project: TheOink   File: OinkSausage.java   View source code 5 votes vote down vote up
@Override
public void onDeath(DamageSource cause) {
    super.onDeath(cause);
    if (!this.world.isRemote)
    {
        this.dead = true;
        this.world.createExplosion(this, this.posX, this.posY, this.posZ, 50F, false);
        this.setDead();
    }
}
 
Example 40
Project: BaseClient   File: Entity.java   View source code 5 votes vote down vote up
/**
 * Called whenever the entity is walking inside of lava.
 */
protected void setOnFireFromLava()
{
    if (!this.isImmuneToFire)
    {
        this.attackEntityFrom(DamageSource.lava, 4.0F);
        this.setFire(15);
    }
}