当前位置: 首页>>代码示例>>Java>>正文


Java EnchantmentProtection.getBlastDamageReduction方法代码示例

本文整理汇总了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));
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:InfinityStudio,项目名称:InspiringWorld,代码行数:61,代码来源:SourceBombExplosion.java


注:本文中的net.minecraft.enchantment.EnchantmentProtection.getBlastDamageReduction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。