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


Java DamageEntityEvent.getFinalDamage方法代码示例

本文整理汇总了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());
			}
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:25,代码来源:SkillSoulbind.java

示例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);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:12,代码来源:EntityDamagedScriptEvent.java

示例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);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:15,代码来源:EntityKilledScriptEvent.java

示例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);
    }
}
 
开发者ID:games647,项目名称:HealthName,代码行数:11,代码来源:DamageListener.java


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