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


Java Living.getOrCreate方法代码示例

本文整理汇总了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."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:18,代码来源:FearBlaze.java

示例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."));
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:Agility.java

示例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."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:18,代码来源:MagicChain.java

示例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."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:Regen.java

示例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."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:22,代码来源:EvilFocus.java

示例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."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:Curse.java

示例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."));

}
 
开发者ID:Skelril,项目名称:Skree,代码行数:18,代码来源:Confuse.java

示例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."));
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:Weaken.java


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