本文整理汇总了Java中org.spongepowered.api.event.entity.DamageEntityEvent.getFinalDamage方法的典型用法代码示例。如果您正苦于以下问题:Java DamageEntityEvent.getFinalDamage方法的具体用法?Java DamageEntityEvent.getFinalDamage怎么用?Java DamageEntityEvent.getFinalDamage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.entity.DamageEntityEvent
的用法示例。
在下文中一共展示了DamageEntityEvent.getFinalDamage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDamage
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LAST)
public void onEntityDamage(DamageEntityEvent event) {
if (event.isCancelled() || event.getFinalDamage() == 0) {
return;
}
if (event.getTargetEntity().getType() == EntityTypes.PLAYER) {
UUID id = event.getTargetEntity().getUniqueId();
IActiveCharacter character = characterService.getCharacter(id);
IEffectContainer container = character.getEffect(name);
if (container == null)
return;
if (!event.getCause().first(SoulBindEffect.class).isPresent()) {
event.setBaseDamage(event.getBaseDamage() * .5);
SoulBindEffect effect = (SoulBindEffect) container;
SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
if (effect.getConsumer() == character) {
effect.getTarget().getEntity().damage(event.getBaseDamage(), builder.build());
} else {
effect.getConsumer().getEntity().damage(event.getBaseDamage(), builder.build());
}
}
}
}
示例2: onEntityDamaged
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityDamaged(DamageEntityEvent evt) {
EntityDamagedScriptEvent event = (EntityDamagedScriptEvent) clone();
event.internal = evt;
event.entity = new EntityTag(evt.getTargetEntity());
event.damage = new NumberTag(evt.getFinalDamage());
event.cancelled = evt.isCancelled();
// TODO: Cause viewing
event.run();
evt.setCancelled(event.cancelled);
}
示例3: onEntityKilled
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityKilled(DamageEntityEvent evt) {
if (!evt.willCauseDeath()) {
return;
}
EntityKilledScriptEvent event = (EntityKilledScriptEvent) clone();
event.internal = evt;
event.entity = new EntityTag(evt.getTargetEntity());
event.damage = new NumberTag(evt.getFinalDamage());
event.cancelled = evt.isCancelled();
// TODO: Cause viewing
event.run();
evt.setCancelled(event.cancelled);
}
示例4: onEntityDamage
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityDamage(DamageEntityEvent damageEntityEvent) {
Entity targetEntity = damageEntityEvent.getTargetEntity();
Optional<Double> optionalHealth = targetEntity.get(Keys.HEALTH);
Optional<Double> optionalMaxHealth = targetEntity.get(Keys.MAX_HEALTH);
if (optionalHealth.isPresent() && optionalMaxHealth.isPresent()) {
double newHealth = optionalHealth.get() - damageEntityEvent.getFinalDamage();
updateHealth(optionalMaxHealth.get(), newHealth, targetEntity);
}
}