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


Java CraftEventFactory.callEntityDamageEvent方法代码示例

本文整理汇总了Java中org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDamageEvent方法的典型用法代码示例。如果您正苦于以下问题:Java CraftEventFactory.callEntityDamageEvent方法的具体用法?Java CraftEventFactory.callEntityDamageEvent怎么用?Java CraftEventFactory.callEntityDamageEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.craftbukkit.event.CraftEventFactory的用法示例。


在下文中一共展示了CraftEventFactory.callEntityDamageEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: b

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
protected void b(float f) {
    super.b(f);
    MobEffect mobeffect = this.getEffect(MobEffectList.JUMP);
    float f1 = mobeffect != null ? (float) (mobeffect.getAmplifier() + 1) : 0.0F;
    // CraftBukkit start
    float i = MathHelper.f(f - 3.0F - f1);

    if (i > 0) {
        EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(null, this, EntityDamageEvent.DamageCause.FALL, i);
        if (event.isCancelled()) {
            return;
        }

        i = (float) event.getDamage();
        if (i > 0) {
            this.getBukkitEntity().setLastDamageCause(event);
        }
    }
    // CraftBukkit end

    if (i > 0) {
        if (i > 4) {
            this.makeSound("damage.fallbig", 1.0F, 1.0F);
        } else {
            this.makeSound("damage.fallsmall", 1.0F, 1.0F);
        }

        this.damageEntity(DamageSource.FALL, (float) i);
        int j = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height), MathHelper.floor(this.locZ));

        if (j > 0) {
            StepSound stepsound = Block.byId[j].stepSound;

            this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F);
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:38,代码来源:EntityLiving.java

示例2: b

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
protected void b(float f) {
    if (this.hurtEntities) {
        int i = MathHelper.f(f - 1.0F);

        if (i > 0) {
            ArrayList arraylist = new ArrayList(this.world.getEntities(this, this.boundingBox));
            DamageSource damagesource = this.id == Block.ANVIL.id ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK;
            Iterator iterator = arraylist.iterator();

            while (iterator.hasNext()) {
                Entity entity = (Entity) iterator.next();

                // CraftBukkit start
                float damage = (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax);

                EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(this, entity, EntityDamageEvent.DamageCause.FALLING_BLOCK, damage);
                if (event.isCancelled()) {
                    continue;
                }

                entity.damageEntity(damagesource, (float) event.getDamage());
                // CraftBukkit end
            }

            if (this.id == Block.ANVIL.id && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) {
                int j = this.data >> 2;
                int k = this.data & 3;

                ++j;
                if (j > 2) {
                    this.f = true;
                } else {
                    this.data = k | j << 2;
                }
            }
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:39,代码来源:EntityFallingBlock.java


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