本文整理汇总了Java中org.spongepowered.api.entity.living.Living.getOrCreate方法的典型用法代码示例。如果您正苦于以下问题:Java Living.getOrCreate方法的具体用法?Java Living.getOrCreate怎么用?Java Living.getOrCreate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.entity.living.Living
的用法示例。
在下文中一共展示了Living.getOrCreate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
int duration = (int) (EntityHealthUtil.getHealth(owner) * 20);
Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (optPotionEffectData.isPresent()) {
PotionEffectData potionEffectData = optPotionEffectData.get();
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.BLINDNESS, 1, duration));
target.offer(potionEffectData);
}
target.offer(Keys.FIRE_TICKS, duration);
notify(owner, Text.of(TextColors.YELLOW, "Your sword releases a deadly blaze."));
}
示例2: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
int duration = (int) Math.min(20 * 60 * 5, EntityHealthUtil.getHealth(owner) * 18);
Optional<PotionEffectData> optOwnerPotionEffectData = owner.getOrCreate(PotionEffectData.class);
if (optOwnerPotionEffectData.isPresent()) {
PotionEffectData ownerPotionEffectData = optOwnerPotionEffectData.get();
ownerPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SPEED, 2, duration));
owner.offer(ownerPotionEffectData);
}
Optional<PotionEffectData> optTargetPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (optTargetPotionEffectData.isPresent()) {
PotionEffectData targetPotionEffectData = optTargetPotionEffectData.get();
targetPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, duration));
target.offer(targetPotionEffectData);
}
if (optOwnerPotionEffectData.isPresent() || optTargetPotionEffectData.isPresent()) {
notify(owner, Text.of(TextColors.YELLOW, "You gain an agile advantage over your opponent."));
}
}
示例3: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (!optPotionEffectData.isPresent()) {
return;
}
PotionEffectData potionEffectData = optPotionEffectData.get();
int duration = (int) (EntityHealthUtil.getHealth(owner) * 18);
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, duration));
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.WEAKNESS, 2, duration));
target.offer(potionEffectData);
notify(owner, Text.of(TextColors.YELLOW, "Your bow slows its victim."));
}
示例4: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
Optional<PotionEffectData> optPotionEffectData = owner.getOrCreate(PotionEffectData.class);
if (!optPotionEffectData.isPresent()) {
return;
}
PotionEffectData potionEffectData = optPotionEffectData.get();
int duration = (int) (EntityHealthUtil.getHealth(target) * 10);
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.REGENERATION, 2, duration));
owner.offer(potionEffectData);
notify(owner, Text.of(TextColors.YELLOW, "You gain a healing aura."));
}
示例5: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (!optPotionEffectData.isPresent()) {
return;
}
PotionEffectData potionEffectData = optPotionEffectData.get();
int duration = (int) (EntityHealthUtil.getHealth(target) * 10);
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 9, duration));
if (target instanceof Player) {
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.BLINDNESS, 0, 20 * 4));
}
target.offer(potionEffectData);
target.getWorld().playSound(SoundTypes.ENTITY_GHAST_SCREAM, target.getLocation().getPosition(), 1, .02F);
notify(owner, Text.of(TextColors.YELLOW, "Your weapon traps your foe in their own sins."));
}
示例6: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (!optPotionEffectData.isPresent()) {
return;
}
PotionEffectData potionEffectData = optPotionEffectData.get();
int duration = (int) Math.min(20 * 60 * 5, EntityHealthUtil.getHealth(owner) * 24);
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.WITHER, 2, duration));
target.offer(potionEffectData);
notify(owner, Text.of(TextColors.YELLOW, "Your weapon curses its victim."));
}
示例7: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (!optPotionEffectData.isPresent()) {
return;
}
PotionEffectData potionEffectData = optPotionEffectData.get();
int duration = (int) Math.min(1200, EntityHealthUtil.getHealth(owner) * 18);
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.NAUSEA, 1, duration));
target.offer(potionEffectData);
notify(owner, Text.of(TextColors.YELLOW, "Your sword confuses its victim."));
}
示例8: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
int duration = (int) Math.min(20 * 60 * 5, EntityHealthUtil.getHealth(owner) * 18);
Optional<PotionEffectData> optOwnerPotionEffectData = owner.getOrCreate(PotionEffectData.class);
if (optOwnerPotionEffectData.isPresent()) {
PotionEffectData ownerPotionEffectData = optOwnerPotionEffectData.get();
ownerPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.STRENGTH, 1, duration));
owner.offer(ownerPotionEffectData);
}
Optional<PotionEffectData> optTargetPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (optTargetPotionEffectData.isPresent()) {
PotionEffectData targetPotionEffectData = optTargetPotionEffectData.get();
targetPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.WEAKNESS, 1, duration));
target.offer(targetPotionEffectData);
}
if (optOwnerPotionEffectData.isPresent() || optTargetPotionEffectData.isPresent()) {
notify(owner, Text.of(TextColors.YELLOW, "Your sword leaches strength from its victim."));
}
}