本文整理汇总了Java中net.minecraft.enchantment.EnchantmentProtection.getBlastDamageReduction方法的典型用法代码示例。如果您正苦于以下问题:Java EnchantmentProtection.getBlastDamageReduction方法的具体用法?Java EnchantmentProtection.getBlastDamageReduction怎么用?Java EnchantmentProtection.getBlastDamageReduction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.enchantment.EnchantmentProtection
的用法示例。
在下文中一共展示了EnchantmentProtection.getBlastDamageReduction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExplosionA
import net.minecraft.enchantment.EnchantmentProtection; //导入方法依赖的package包/类
/**
* Does the first part of the explosion (only make damage to entities)
*/
@Override
public void doExplosionA() {
float f3 = this.explosionSize * 2.0F;
int k1 = MathHelper.floor_double(this.explosionX - f3 - 1.0D);
int l1 = MathHelper.floor_double(this.explosionX + f3 + 1.0D);
int i2 = MathHelper.floor_double(this.explosionY - f3 - 1.0D);
int i1 = MathHelper.floor_double(this.explosionY + f3 + 1.0D);
int j2 = MathHelper.floor_double(this.explosionZ - f3 - 1.0D);
int j1 = MathHelper.floor_double(this.explosionZ + f3 + 1.0D);
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this.exploder,
new AxisAlignedBB(k1, i2, j2, l1, i1, j1));
net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.worldObj, this, list, f3);
Vec3d vec3d = new Vec3d(this.explosionX, this.explosionY, this.explosionZ);
for (Entity entity : list) {
if (!entity.isImmuneToExplosions()) {
double d12 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / f3;
if (d12 <= 1.0D) {
double d5 = entity.posX - this.explosionX;
double d7 = entity.posY + entity.getEyeHeight() - this.explosionY;
double d9 = entity.posZ - this.explosionZ;
double d13 = MathHelper.sqrt_double(d5 * d5 + d7 * d7 + d9 * d9);
if (d13 != 0.0D) {
d5 = d5 / d13;
d7 = d7 / d13;
d9 = d9 / d13;
double d14 = this.worldObj.getBlockDensity(vec3d, entity.getEntityBoundingBox());
double d10 = (1.0D - d12) * d14;
entity.attackEntityFrom(
new EntityDamageSource("explosion", exploder).setDifficultyScaled().setExplosion(),
((int) ((d10 * d10 + d10) / 2.0D * 7.0D * f3 + 1.0D)));
double d11 = 1.0D;
if (entity instanceof EntityLivingBase) {
d11 = EnchantmentProtection.getBlastDamageReduction((EntityLivingBase) entity, d10);
}
entity.motionX += d5 * d11;
entity.motionY += d7 * d11;
entity.motionZ += d9 * d11;
if (entity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entity;
if (!entityplayer.isSpectator() &&
(!entityplayer.isCreative() || !entityplayer.capabilities.isFlying)) {
this.playerKnockbackMap.put(entityplayer, new Vec3d(d5 * d10, d7 * d10, d9 * d10));
}
}
}
}
}
}
}