本文整理汇总了Java中org.spongepowered.api.entity.living.Living.offer方法的典型用法代码示例。如果您正苦于以下问题:Java Living.offer方法的具体用法?Java Living.offer怎么用?Java Living.offer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.entity.living.Living
的用法示例。
在下文中一共展示了Living.offer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
final double ownerMax = getMaxHealth(owner);
final double targetMax = getMaxHealth(target);
final double ownerHP = getHealth(owner) / ownerMax;
final double targetHP = getHealth(target) / targetMax;
if (ownerHP > targetHP) {
owner.offer(Keys.HEALTH, Math.min(ownerMax, ownerMax * (ownerHP + .1)));
notify(owner, Text.of(TextColors.YELLOW, "Your weapon heals you."));
} else {
target.offer(Keys.HEALTH, targetMax * ownerHP);
owner.offer(Keys.HEALTH, Math.min(ownerMax, ownerMax * targetHP * 1.1));
notify(owner, Text.of(TextColors.YELLOW, "You leech the health of your foe."));
}
}
示例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) (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."));
}
示例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(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."));
}
示例8: 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."));
}
示例9: 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."));
}
}
示例10: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
final double targetMax = getMaxHealth(target);
final double targetHP = getHealth(target) / targetMax;
target.offer(Keys.HEALTH, (targetHP / 2) * targetMax);
Task.builder().delayTicks(20 * (int) Math.min(20, targetMax / 5 + 1)).execute(() -> {
if (!target.isRemoved()) {
double newTargetMax = getMaxHealth(target);
double newTargetHP = getHealth(target) / newTargetMax;
if (newTargetHP < targetHP) {
target.offer(Keys.HEALTH, targetHP * newTargetMax);
}
}
notify(owner, Text.of(TextColors.YELLOW, "Your sword releases its grasp on its victim."));
}).submit(SkreePlugin.inst());
notify(owner, Text.of(TextColors.YELLOW, "Your sword steals its victims health for a short time."));
}
示例11: 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);
}
示例12: processAttackOnEntity
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public void processAttackOnEntity(Living attacker, DamageEntityEvent event) {
int diff = (int) (getMaxHealth(attacker) - getHealth(attacker));
double randomRelative = Probability.getRandom(Probability.getRandom(Math.pow(diff, 2)));
event.setBaseDamage(Math.max(5, randomRelative));
// Damage the user by 1 damage
attacker.offer(Keys.HEALTH, getHealth(attacker) - 1);
}
示例13: processAttackOnPlayer
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public void processAttackOnPlayer(Living attacker, Player defender, DamageEntityEvent event) {
event.setBaseDamage(0);
Living target = defender;
if (Probability.getChance(2)) {
target = attacker;
}
double targetHealth = getHealth(target);
target.offer(Keys.HEALTH, Math.max(0, targetHealth - 16));
}
示例14: run
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
if (target.get(Keys.FOOD_LEVEL).isPresent() && target.get(Keys.SATURATION).isPresent()) {
target.offer(Keys.FOOD_LEVEL, (int) (target.get(Keys.FOOD_LEVEL).get() * .85));
target.offer(Keys.FOOD_LEVEL, (int) (target.get(Keys.FOOD_LEVEL).get() * .85));
target.offer(Keys.SATURATION, 0D);
} else {
EntityHealthUtil.setMaxHealth(target, EntityHealthUtil.getMaxHealth(target) * .9, false);
}
notify(owner, Text.of(TextColors.YELLOW, "You drain the stamina of your foe."));
}
示例15: setMaxHealth
import org.spongepowered.api.entity.living.Living; //导入方法依赖的package包/类
public static void setMaxHealth(Living living, double amt, boolean fill) {
if (amt < living.get(Keys.MAX_HEALTH).get() && living.get(Keys.HEALTH).get() > amt) {
living.offer(Keys.HEALTH, amt);
}
living.offer(Keys.MAX_HEALTH, amt);
if (fill) {
toFullHealth(living);
}
}