本文整理匯總了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);
}
}
}
}