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


Java ForgeHooks.onLivingAttack方法代码示例

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


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

示例1: attackEntityFrom

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
	if (ForgeHooks.onLivingAttack(this, p_70097_1_, p_70097_2_)) {
		return false;
	}
	if (isEntityInvulnerable()) {
		return false;
	}
	if ((this.capabilities.disableDamage) && (!p_70097_1_.canHarmInCreative())) {
		return false;
	}
	this.entityAge = 0;
	if (getHealth() <= 0.0F) {
		return false;
	}
	if ((isPlayerSleeping()) && (!this.worldObj.isRemote)) {
		wakeUpPlayer(true, true, false);
	}
	if (p_70097_1_.isDifficultyScaled())
	{
		if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) {
			p_70097_2_ = 0.0F;
		}
		if (this.worldObj.difficultySetting == EnumDifficulty.EASY) {
			p_70097_2_ = p_70097_2_ / 2.0F + 1.0F;
		}
		if (this.worldObj.difficultySetting == EnumDifficulty.HARD) {
			p_70097_2_ = p_70097_2_ * 3.0F / 2.0F;
		}
	}
	if (p_70097_2_ == 0.0F) {
		return false;
	}
	Entity entity = p_70097_1_.getEntity();
	if (((entity instanceof EntityArrow)) && (((EntityArrow)entity).shootingEntity != null)) {
		entity = ((EntityArrow)entity).shootingEntity;
	}
	addStat(StatList.damageTakenStat, Math.round(p_70097_2_ * 10.0F));
	return super.attackEntityFrom(p_70097_1_, p_70097_2_);
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:41,代码来源:EntityPlayer.java

示例2: attackEntityFrom

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
    if (ForgeHooks.onLivingAttack(this, p_70097_1_, p_70097_2_)) return false;
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else if (this.capabilities.disableDamage && !p_70097_1_.canHarmInCreative())
    {
        return false;
    }
    else
    {
        this.entityAge = 0;

        if (this.getHealth() <= 0.0F)
        {
            return false;
        }
        else
        {
            if (this.isPlayerSleeping() && !this.worldObj.isRemote)
            {
                this.wakeUpPlayer(true, true, false);
            }

            if (p_70097_1_.isDifficultyScaled())
            {
                if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL)
                {
                    return false; // CraftBukkit - p_70097_2_ = 0.0F; -> return false
                }

                if (this.worldObj.difficultySetting == EnumDifficulty.EASY)
                {
                    p_70097_2_ = p_70097_2_ / 2.0F + 1.0F;
                }

                if (this.worldObj.difficultySetting == EnumDifficulty.HARD)
                {
                    p_70097_2_ = p_70097_2_ * 3.0F / 2.0F;
                }
            }

            if (false && p_70097_2_ == 0.0F)   // CraftBukkit - Don't filter out 0 damage
            {
                return false;
            }
            else
            {
                Entity entity = p_70097_1_.getEntity();

                if (entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity != null)
                {
                    entity = ((EntityArrow)entity).shootingEntity;
                }

                this.addStat(StatList.damageTakenStat, Math.round(p_70097_2_ * 10.0F));
                return super.attackEntityFrom(p_70097_1_, p_70097_2_);
            }
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:64,代码来源:EntityPlayer.java

示例3: attackEntityFrom

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
    if (ForgeHooks.onLivingAttack(this, p_70097_1_, p_70097_2_)) return false;
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else if (this.capabilities.disableDamage && !p_70097_1_.canHarmInCreative())
    {
        return false;
    }
    else
    {
        this.entityAge = 0;

        if (this.getHealth() <= 0.0F)
        {
            return false;
        }
        else
        {
            if (this.isPlayerSleeping() && !this.worldObj.isRemote)
            {
                this.wakeUpPlayer(true, true, false);
            }

            if (p_70097_1_.isDifficultyScaled())
            {
                if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL)
                {
                    p_70097_2_ = 0.0F;
                }

                if (this.worldObj.difficultySetting == EnumDifficulty.EASY)
                {
                    p_70097_2_ = p_70097_2_ / 2.0F + 1.0F;
                }

                if (this.worldObj.difficultySetting == EnumDifficulty.HARD)
                {
                    p_70097_2_ = p_70097_2_ * 3.0F / 2.0F;
                }
            }

            if (p_70097_2_ == 0.0F)
            {
                return false;
            }
            else
            {
                Entity entity = p_70097_1_.getEntity();

                if (entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity != null)
                {
                    entity = ((EntityArrow)entity).shootingEntity;
                }

                this.addStat(StatList.damageTakenStat, Math.round(p_70097_2_ * 10.0F));
                return super.attackEntityFrom(p_70097_1_, p_70097_2_);
            }
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:64,代码来源:EntityPlayer.java

示例4: attackEntityFrom

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
    if (ForgeHooks.onLivingAttack(this, par1DamageSource, par2)) return false;
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else if (this.capabilities.disableDamage && !par1DamageSource.canHarmInCreative())
    {
        return false;
    }
    else
    {
        this.entityAge = 0;

        if (this.getHealth() <= 0.0F)
        {
            return false;
        }
        else
        {
            if (this.isPlayerSleeping() && !this.worldObj.isRemote)
            {
                this.wakeUpPlayer(true, true, false);
            }

            if (par1DamageSource.isDifficultyScaled())
            {
                if (this.worldObj.difficultySetting == 0)
                {
                    par2 = 0.0F;
                }

                if (this.worldObj.difficultySetting == 1)
                {
                    par2 = par2 / 2.0F + 1.0F;
                }

                if (this.worldObj.difficultySetting == 3)
                {
                    par2 = par2 * 3.0F / 2.0F;
                }
            }

            if (par2 == 0.0F)
            {
                return false;
            }
            else
            {
                Entity entity = par1DamageSource.getEntity();

                if (entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity != null)
                {
                    entity = ((EntityArrow)entity).shootingEntity;
                }

                this.addStat(StatList.damageTakenStat, Math.round(par2 * 10.0F));
                return super.attackEntityFrom(par1DamageSource, par2);
            }
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:67,代码来源:EntityPlayer.java


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