• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EntityRegainHealthEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中cn.nukkit.event.entity.EntityRegainHealthEvent的典型用法代码示例。如果您正苦于以下问题:Java EntityRegainHealthEvent类的具体用法?Java EntityRegainHealthEvent怎么用?Java EntityRegainHealthEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EntityRegainHealthEvent类属于cn.nukkit.event.entity包,在下文中一共展示了EntityRegainHealthEvent类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: applyEffect

import cn.nukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
public void applyEffect(Entity entity) {
    switch (this.id) {
        case Effect.POISON: //POISON
            if (entity.getHealth() > 1) {
                entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, 1));
            }
            break;
        case Effect.WITHER: //WITHER
            entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, 1));
            break;
        case Effect.REGENERATION: //REGENERATION
            if (entity.getHealth() < entity.getMaxHealth()) {
                entity.heal(new EntityRegainHealthEvent(entity, 1, EntityRegainHealthEvent.CAUSE_MAGIC));
            }
            break;
        case Effect.SPEED:
            if (entity instanceof Player) {
                ((Player) entity).setMovementSpeed((float) (((this.amplifier + 1) * 0.2 + 1) * 0.1));
            }
            break;
        case Effect.SLOWNESS:
            if (entity instanceof Player) {
                ((Player) entity).setMovementSpeed((float) (((this.amplifier + 1) * -0.15 + 1) * 0.1));
            }
            break;
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:28,代码来源:Effect.java


示例2: heal

import cn.nukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@Override
public void heal(EntityRegainHealthEvent source) {
    super.heal(source);
    if (source.isCancelled()) {
        return;
    }

    this.attackTime = 0;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:10,代码来源:EntityLiving.java


示例3: heal

import cn.nukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
public void heal(EntityRegainHealthEvent source) {
    this.server.getPluginManager().callEvent(source);
    if (source.isCancelled()) {
        return;
    }
    this.setHealth(this.getHealth() + source.getAmount());
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:8,代码来源:Entity.java


示例4: applyPotion

import cn.nukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
public void applyPotion(Entity entity, double health) {
    if (!(entity instanceof EntityLiving)) {
        return;
    }

    Effect applyEffect = getEffect(this.getId(), this.isSplash());

    if (applyEffect == null) {
        return;
    }

    if (entity instanceof Player) {
        if (!((Player) entity).isSurvival() && applyEffect.isBad()) {
            return;
        }
    }

    PotionApplyEvent event = new PotionApplyEvent(this, entity);

    entity.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        return;
    }

    switch (this.getId()) {
        case INSTANT_HEALTH:
        case INSTANT_HEALTH_II:
            entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_EATING));
            break;
        case HARMING:
        case HARMING_II:
            entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1)))));
            break;
        default:
            int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5);
            applyEffect.setDuration(duration);
            entity.addEffect(applyEffect);
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:40,代码来源:Potion.java


示例5: applyPotion

import cn.nukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
public void applyPotion(Entity entity, double health) {
    if (!(entity instanceof EntityLiving)) {
        return;
    }

    Effect applyEffect = getEffect(this.getId(), this.isSplash());

    if (applyEffect == null) {
        return;
    }

    if (entity instanceof Player) {
        if (!((Player) entity).isSurvival() && applyEffect.isBad()) {
            return;
        }
    }

    PotionApplyEvent event = new PotionApplyEvent(this, entity);

    entity.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        return;
    }

    switch (this.getId()) {
        case INSTANT_HEALTH:
        case INSTANT_HEALTH_II:
            entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_EATING));
            break;
        case HARMING:
        case HARMING_II:
            entity.attack(new EntityDamageEvent(entity, EntityDamageEvent.CAUSE_MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1)))));
            break;
        default:
            int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5);
            applyEffect.setDuration(duration);
            entity.addEffect(applyEffect);
    }
}
 
开发者ID:NycuRO,项目名称:Apollo-OLD,代码行数:40,代码来源:Potion.java


示例6: applyPotion

import cn.nukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
public void applyPotion(Entity entity, double health) {
    if (!(entity instanceof EntityLiving)) {
        return;
    }

    Effect applyEffect = getEffect(this.getId(), this.isSplash());

    if (applyEffect == null) {
        return;
    }

    if (entity instanceof Player) {
        if (!((Player) entity).isSurvival() && applyEffect.isBad()) {
            return;
        }
    }

    PotionApplyEvent event = new PotionApplyEvent(this, applyEffect, entity);

    entity.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        return;
    }

    applyEffect = event.getApplyEffect();

    switch (this.getId()) {
        case INSTANT_HEALTH:
        case INSTANT_HEALTH_II:
            entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_EATING));
            break;
        case HARMING:
        case HARMING_II:
            entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1)))));
            break;
        default:
            int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5);
            applyEffect.setDuration(duration);
            entity.addEffect(applyEffect);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:42,代码来源:Potion.java


示例7: applyPotion

import cn.nukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
public void applyPotion(Entity entity) {
    if (!(entity instanceof EntityLiving)) {
        return;
    }

    Effect applyEffect = getEffect(this.getId(), this.isSplash());

    if (applyEffect == null) {
        return;
    }

    if (entity instanceof Player) {
        if (!((Player) entity).isSurvival() && applyEffect.isBad()) {
            return;
        }
    }

    PotionApplyEvent event = new PotionApplyEvent(this, entity);

    entity.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        return;
    }

    switch (this.getId()) {
        case INSTANT_HEALTH:
            entity.heal(new EntityRegainHealthEvent(entity, 4, EntityRegainHealthEvent.CAUSE_EATING));
            break;
        case INSTANT_HEALTH_II:
            entity.heal(new EntityRegainHealthEvent(entity, 8, EntityRegainHealthEvent.CAUSE_EATING));
            break;
        case HARMING:
            entity.attack(new EntityDamageEvent(entity, EntityDamageEvent.CAUSE_MAGIC, 6));
            break;
        case HARMING_II:
            entity.attack(new EntityDamageEvent(entity, EntityDamageEvent.CAUSE_MAGIC, 12));
            break;
        default:
            entity.addEffect(applyEffect);
    }
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:42,代码来源:Potion.java


示例8: onEntityRegainHealth

import cn.nukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
    if (event.getRegainReason() == EntityRegainHealthEvent.CAUSE_REGEN) {
        event.setCancelled(!api.isNaturalRegeneration(event.getEntity().getLevel()));
    }
}
 
开发者ID:yescallop,项目名称:EssentialsNK,代码行数:7,代码来源:EventListener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EurekaServerContextHolder类代码示例发布时间:2022-05-22
下一篇:
Java DataParam类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap