本文整理汇总了Java中net.minecraft.util.DamageSource.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java DamageSource.getEntity方法的具体用法?Java DamageSource.getEntity怎么用?Java DamageSource.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.DamageSource
的用法示例。
在下文中一共展示了DamageSource.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
{
Entity entity = source.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
amount = (amount + 1.0F) / 2.0F;
}
return super.attackEntityFrom(source, amount);
}
}
示例2: 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
{
Entity entity = source.getEntity();
if (entity instanceof EntityPlayer)
{
this.becomeAngryAt(entity);
}
return super.attackEntityFrom(source, amount);
}
}
示例3: 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);
}
}
示例4: 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.addStat(AchievementList.SNIPE_SKELETON);
}
}
}
示例5: 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;
}
示例6: onDeath
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* Called when the mob's health reaches 0.
*/
public void onDeath(DamageSource cause)
{
if (this.villageObj != null)
{
Entity entity = cause.getEntity();
if (entity != null)
{
if (entity instanceof EntityPlayer)
{
this.villageObj.modifyPlayerReputation(entity.getName(), -2);
}
else if (entity instanceof IMob)
{
this.villageObj.endMatingSeason();
}
}
else
{
EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, 16.0D);
if (entityplayer != null)
{
this.villageObj.endMatingSeason();
}
}
}
super.onDeath(cause);
}
示例7: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (!this.worldObj.isRemote && !this.isDead)
{
if (this.isEntityInvulnerable(source))
{
return false;
}
else
{
this.setRollingDirection(-this.getRollingDirection());
this.setRollingAmplitude(10);
this.setBeenAttacked();
this.setDamage(this.getDamage() + amount * 10.0F);
boolean flag = source.getEntity() instanceof EntityPlayer && ((EntityPlayer)source.getEntity()).capabilities.isCreativeMode;
if (flag || this.getDamage() > 40.0F)
{
this.removePassengers();
if (flag && !this.hasCustomName())
{
this.setDead();
}
else
{
this.killMinecart(source);
}
}
return true;
}
}
else
{
return true;
}
}
示例8: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
@Override
public boolean attackEntityFrom(DamageSource source, float par2) // Big rockets can be swatted out of the way with a bit of expertise
{
if (this.isEntityInvulnerable()) { return false; }
else // Not invulnerable
{
this.setBeenAttacked();
if (source.getEntity() != null) // Damaged by a entity
{
Vec3 vec3 = source.getEntity().getLookVec(); // Which is looking that way...
if (vec3 != null)
{
this.motionX = vec3.xCoord;
this.motionY = vec3.yCoord;
this.motionZ = vec3.zCoord;
}
if (source.getEntity() instanceof EntityLivingBase) { this.shootingEntity = (EntityLivingBase)source.getEntity(); }
return true;
}
// else, not damaged by an entity
}
return false;
}
示例9: 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 && !(this instanceof EntityPigZombie) && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
{
((EntityCreeper)cause.getEntity()).func_175493_co();
this.entityDropItem(new ItemStack(Items.skull, 1, 2), 0.0F);
}
}
示例10: 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 && !(this instanceof EntityPigZombie) && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
{
((EntityCreeper)cause.getEntity()).incrementDroppedSkulls();
this.entityDropItem(new ItemStack(Items.SKULL, 1, 2), 0.0F);
}
}
示例11: onDeath
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* Called when the mob's health reaches 0.
*/
public void onDeath(DamageSource cause)
{
if (!this.dead)
{
Entity entity = cause.getEntity();
EntityLivingBase entitylivingbase = this.getAttackingEntity();
if (this.scoreValue >= 0 && entitylivingbase != null)
{
entitylivingbase.addToPlayerScore(this, this.scoreValue);
}
if (entity != null)
{
entity.onKillEntity(this);
}
this.dead = true;
this.getCombatTracker().reset();
if (!this.world.isRemote)
{
int i = 0;
if (entity instanceof EntityPlayer)
{
i = EnchantmentHelper.getLootingModifier((EntityLivingBase)entity);
}
if (this.canDropLoot() && this.world.getGameRules().getBoolean("doMobLoot"))
{
boolean flag = this.recentlyHit > 0;
this.dropLoot(flag, i, cause);
}
}
this.world.setEntityState(this, (byte)3);
}
}
示例12: 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();
if (source.getEntity() != null)
{
Vec3 vec3 = source.getEntity().getLookVec();
if (vec3 != null)
{
this.motionX = vec3.xCoord;
this.motionY = vec3.yCoord;
this.motionZ = vec3.zCoord;
this.accelerationX = this.motionX * 0.1D;
this.accelerationY = this.motionY * 0.1D;
this.accelerationZ = this.motionZ * 0.1D;
}
if (source.getEntity() instanceof EntityLivingBase)
{
this.shootingEntity = (EntityLivingBase)source.getEntity();
}
return true;
}
else
{
return false;
}
}
}
示例13: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (!this.worldObj.isRemote && !this.isDead)
{
if (this.isEntityInvulnerable(source))
{
return false;
}
else
{
this.setRollingDirection(-this.getRollingDirection());
this.setRollingAmplitude(10);
this.setBeenAttacked();
this.setDamage(this.getDamage() + amount * 10.0F);
boolean flag = source.getEntity() instanceof EntityPlayer && ((EntityPlayer)source.getEntity()).capabilities.isCreativeMode;
if (flag || this.getDamage() > 40.0F)
{
if (this.riddenByEntity != null)
{
this.riddenByEntity.mountEntity((Entity)null);
}
if (flag && !this.hasCustomName())
{
this.setDead();
}
else
{
this.killMinecart(source);
}
}
return true;
}
}
else
{
return true;
}
}
示例14: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
Entity entity = source.getEntity();
return this.riddenByEntity != null && this.riddenByEntity.equals(entity) ? false : super.attackEntityFrom(source, amount);
}
示例15: attackEntityFromPart
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
public boolean attackEntityFromPart(EntityDragonPart dragonPart, DamageSource source, float damage)
{
damage = this.phaseManager.getCurrentPhase().getAdjustedDamage(dragonPart, source, damage);
if (dragonPart != this.dragonPartHead)
{
damage = damage / 4.0F + Math.min(damage, 1.0F);
}
if (damage < 0.01F)
{
return false;
}
else
{
if (source.getEntity() instanceof EntityPlayer || source.isExplosion())
{
float f = this.getHealth();
this.attackDragonFrom(source, damage);
if (this.getHealth() <= 0.0F && !this.phaseManager.getCurrentPhase().getIsStationary())
{
this.setHealth(1.0F);
this.phaseManager.setPhase(PhaseList.DYING);
}
if (this.phaseManager.getCurrentPhase().getIsStationary())
{
this.sittingDamageReceived = (int)((float)this.sittingDamageReceived + (f - this.getHealth()));
if ((float)this.sittingDamageReceived > 0.25F * this.getMaxHealth())
{
this.sittingDamageReceived = 0;
this.phaseManager.setPhase(PhaseList.TAKEOFF);
}
}
}
return true;
}
}