本文整理汇总了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_);
}
示例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_);
}
}
}
}
示例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_);
}
}
}
}
示例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);
}
}
}
}