本文整理汇总了Java中net.minecraft.util.DamageSource.getSourceOfDamage方法的典型用法代码示例。如果您正苦于以下问题:Java DamageSource.getSourceOfDamage方法的具体用法?Java DamageSource.getSourceOfDamage怎么用?Java DamageSource.getSourceOfDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.DamageSource
的用法示例。
在下文中一共展示了DamageSource.getSourceOfDamage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* 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);
}
示例2: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (!this.isMoving() && !source.isMagicDamage() && source.getSourceOfDamage() instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)source.getSourceOfDamage();
if (!source.isExplosion())
{
entitylivingbase.attackEntityFrom(DamageSource.causeThornsDamage(this), 2.0F);
}
}
if (this.wander != null)
{
this.wander.makeUpdate();
}
return super.attackEntityFrom(source, amount);
}
示例3: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* 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);
}
示例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.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);
}
}
示例5: 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);
}
}
}
示例6: 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);
}
}
else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
{
((EntityCreeper)cause.getEntity()).incrementDroppedSkulls();
this.entityDropItem(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == SkeletonType.WITHER ? 1 : 0), 0.0F);
}
}
示例7: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (this.isClosed())
{
Entity entity = source.getSourceOfDamage();
if (entity instanceof EntityArrow)
{
return false;
}
}
if (super.attackEntityFrom(source, amount))
{
if ((double)this.getHealth() < (double)this.getMaxHealth() * 0.5D && this.rand.nextInt(4) == 0)
{
this.tryTeleportToNewPosition();
}
return true;
}
else
{
return false;
}
}
示例8: 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 if (source != DamageSource.drown && !(source.getEntity() instanceof EntityWither))
{
if (this.getInvulTime() > 0 && source != DamageSource.outOfWorld)
{
return false;
}
else
{
if (this.isArmored())
{
Entity entity = source.getSourceOfDamage();
if (entity instanceof EntityArrow)
{
return false;
}
}
Entity entity1 = source.getEntity();
if (entity1 != null && !(entity1 instanceof EntityPlayer) && entity1 instanceof EntityLivingBase && ((EntityLivingBase)entity1).getCreatureAttribute() == this.getCreatureAttribute())
{
return false;
}
else
{
if (this.blockBreakCounter <= 0)
{
this.blockBreakCounter = 20;
}
for (int i = 0; i < this.field_82224_i.length; ++i)
{
this.field_82224_i[i] += 3;
}
return super.attackEntityFrom(source, amount);
}
}
}
else
{
return false;
}
}
示例9: 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 if (source != DamageSource.drown && !(source.getEntity() instanceof EntityWither))
{
if (this.getInvulTime() > 0 && source != DamageSource.outOfWorld)
{
return false;
}
else
{
if (this.isArmored())
{
Entity entity = source.getSourceOfDamage();
if (entity instanceof EntityArrow)
{
return false;
}
}
Entity entity1 = source.getEntity();
if (entity1 != null && !(entity1 instanceof EntityPlayer) && entity1 instanceof EntityLivingBase && ((EntityLivingBase)entity1).getCreatureAttribute() == this.getCreatureAttribute())
{
return false;
}
else
{
if (this.blockBreakCounter <= 0)
{
this.blockBreakCounter = 20;
}
for (int i = 0; i < this.idleHeadUpdates.length; ++i)
{
this.idleHeadUpdates[i] += 3;
}
return super.attackEntityFrom(source, amount);
}
}
}
else
{
return false;
}
}
示例10: attackEntityFrom
import net.minecraft.util.DamageSource; //导入方法依赖的package包/类
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
if (!worldObj.isRemote && !canInteract) {
if (DamageSource.outOfWorld.equals(source)) {
setDead();
return false;
} else if (isEntityInvulnerable())
return false;
else if (source.isExplosion()) {
dropequipment();
setDead();
return false;
} else if (DamageSource.inFire.equals(source)) {
if (!isBurning())
setFire(5);
else
damageArmorStand(0.15F);
return false;
} else if (DamageSource.onFire.equals(source) && getHealth() > 0.5F) {
damageArmorStand(4.0F);
return false;
} else {
boolean flag = "arrow".equals(source.getDamageType());
boolean flag1 = "player".equals(source.getDamageType());
if (!flag1 && !flag)
return false;
else {
if (source.getSourceOfDamage() instanceof EntityArrow)
source.getSourceOfDamage().setDead();
if (source.getEntity() instanceof EntityPlayer && !((EntityPlayer) source.getEntity()).capabilities.allowEdit)
return false;
else if (source.getEntity() instanceof EntityPlayer && ((EntityPlayer) source.getEntity()).capabilities.isCreativeMode) {
playParticles();
setDead();
return false;
} else {
long i = worldObj.getTotalWorldTime();
if (i - punchCooldown > 5L && !flag)
punchCooldown = i;
else {
dropBlock();
playParticles();
setDead();
}
return false;
}
}
}
} else
return false;
}