本文整理汇总了Java中org.spongepowered.api.entity.living.Living.damage方法的典型用法代码示例。如果您正苦于以下问题:Java Living.damage方法的具体用法?Java Living.damage怎么用?Java Living.damage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.entity.living.Living
的用法示例。
在下文中一共展示了Living.damage方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canDamage
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public static boolean canDamage(IActiveCharacter character, Living l) {
if (character.getPlayer() == l) {
return false;
}
if (l.getType() == EntityTypes.PLAYER) {
if (character.hasParty()) {
IActiveCharacter c = globalScope.characterService.getCharacter(l.getUniqueId());
if (character.getParty().getPlayers().contains(c)) {
return false;
}
}
}
DamageSource build = new SpongeDamageSourceBuilder()
.type(NDamageType.DAMAGE_CHECK)
.absolute()
.build();
return l.damage(0, build);
}
示例2: cast
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public SkillResult cast(IActiveCharacter iActiveCharacter, ExtendedSkillInfo extendedSkillInfo, SkillModifier skillModifier) {
int r = (int) settings.getLevelNodeValue(SkillNodes.RADIUS, extendedSkillInfo.getTotalLevel());
Set<Entity> nearbyEntities = Utils.getNearbyEntities(iActiveCharacter.getPlayer().getLocation(), r);
float damage = settings.getLevelNodeValue(SkillNodes.DAMAGE, extendedSkillInfo.getTotalLevel());
SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
builder.fromSkill(this);
builder.setCaster(iActiveCharacter);
SkillDamageSource src = builder.build();
for (Entity e : nearbyEntities) {
if (Utils.isLivingEntity(e)) {
Living l = (Living) e;
if (Utils.canDamage(iActiveCharacter, l)) {
l.damage(damage, src);
Decorator.strikeLightning(l);
}
}
}
return SkillResult.OK;
}
示例3: castOn
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public SkillResult castOn(Living target, IActiveCharacter source, ExtendedSkillInfo info) {
long duration = getLongNodeValue(info, SkillNodes.DURATION);
double damage = getDoubleNodeValue(info, SkillNodes.DAMAGE);
IEntity e = entityService.get(target);
StunEffect stunEffect = new StunEffect(e, duration);
effectService.addEffect(stunEffect, e, this);
if (damage > 0) {
SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
builder.fromSkill(this);
builder.setTarget(e);
builder.setCaster(source);
SkillDamageSource s = builder.build();
target.damage(damage, s);
}
return SkillResult.OK;
}
示例4: castOn
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public SkillResult castOn(Living target, IActiveCharacter source, ExtendedSkillInfo info) {
Player entity = source.getEntity();
Double max = entity.get(Keys.MAX_HEALTH).get();
Double a = entity.get(Keys.HEALTH).get();
a = max - a;
a *= getFloatNodeValue(info, SkillNodes.MULTIPLIER);
max = getDoubleNodeValue(info, "max-damage");
if (max > 0) {
a = a < max ? max : a;
}
SkillDamageSource build = new SkillDamageSourceBuilder()
.fromSkill(this)
.setTarget(entityService.get(target))
.setCaster(source).build();
target.damage(a, build);
return SkillResult.CANCELLED;
}
示例5: freezeEntities
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
private void freezeEntities() {
Zombie boss = getBoss().get();
double total = 0;
for (Living entity : getContained(Living.class)) {
if (entity.equals(boss)) {
continue;
}
BlockType curType = entity.getLocation().getBlockType();
if (curType != BlockTypes.WATER && curType != BlockTypes.FLOWING_WATER) {
continue;
}
if (entity instanceof Zombie) {
entity.offer(Keys.HEALTH, 0D);
EntityHealthUtil.heal(boss, 1);
total += .02;
} else if (!Probability.getChance(5)) {
entity.damage(Probability.getRandom(25), EntityDamageSource.builder().entity(boss).type(DamageTypes.MAGIC).build());
}
}
modifyDifficulty(-total);
}
示例6: castOn
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public SkillResult castOn(Living target, IActiveCharacter source, ExtendedSkillInfo info) {
float damage = settings.getLevelNodeValue(SkillNodes.DAMAGE, info.getTotalLevel());
SkillDamageSourceBuilder build = new SkillDamageSourceBuilder();
build.fromSkill(this);
build.setCaster(source);
target.damage(damage, build.build());
Decorator.strikeLightning(target);
return SkillResult.OK;
}
示例7: onTick
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void onTick() {
Living entity = getConsumer().getEntity();
if (Utils.canDamage(caster, entity)) {
entity.damage(damage, damageSource);
//todo some particles
NtRpgPlugin.GlobalScope.entityService.healEntity(caster, damage, damageSource.getSkill());
}
}
示例8: damage
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public void damage() {
Living entity = getConsumer().getEntity();
SkillDamageSourceBuilder build = new SkillDamageSourceBuilder();
build.setEffect(this);
build.setCaster(source);
build.type(NDamageType.LIGHTNING);
entity.damage(model.damage, build.build());
Decorator.strikeLightning(entity);
model.timesToHit--;
}
示例9: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
double damage = Probability.getRandom(target instanceof Player ? 3 : 10) * 50;
if (target.damage(damage, damageSource(owner))) {
notify(owner, Text.of(TextColors.YELLOW, "Your sword tears through the flesh of its victim."));
}
}
示例10: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living attacker, DamageEntityEvent event) {
double reflectionAmount = event.getBaseDamage() * modifier;
event.setBaseDamage(event.getBaseDamage() - reflectionAmount);
attacker.damage(Math.max(minimum, reflectionAmount), damageSource(owner));
}
示例11: damage
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public void damage(T boss, Living entity) {
entity.damage(
getDamage(boss.getDetail()),
EntityDamageSource.builder().type(DamageTypes.ATTACK).entity(boss.getTargetEntity().get()).build()
);
}
示例12: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
EntityHealthUtil.heal(owner, 5);
ParticleGenerator.mobSpawnerFlames(target.getLocation(), 4);
target.damage(20, damageSource(owner));
notify(owner, Text.of(TextColors.YELLOW, "Your weapon glows dimly."));
}