本文整理汇总了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;未经允许,请勿转载。 |
请发表评论