本文整理汇总了Java中org.spongepowered.api.entity.living.Living类的典型用法代码示例。如果您正苦于以下问题:Java Living类的具体用法?Java Living怎么用?Java Living使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Living类属于org.spongepowered.api.entity.living包,在下文中一共展示了Living类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDeath
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
@Listener(order = Order.LAST)
public void onEntityDeath(DestructEntityEvent.Death event) {
if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetEntity().getWorld().getProperties())) {
return;
}
GPTimings.ENTITY_DEATH_EVENT.startTimingIfSync();
final Living entity = event.getTargetEntity();
if (!(entity instanceof Player) || !event.getCause().first(EntityDamageSource.class).isPresent()) {
GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
return;
}
// don't do the rest in worlds where claims are not enabled
if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(entity.getWorld().getProperties())) {
GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
return;
}
GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
}
示例2: execute
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
int amount = ctx.<Integer> getOne("amount").get();
EntityType type = ctx.<EntityType> getOne("mob").get();
if (src instanceof Player)
{
Player player = (Player) src;
if (!Living.class.isAssignableFrom(type.getEntityClass()))
{
player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "The mob type you inputted is not a living entity."));
return CommandResult.success();
}
this.spawnEntity(getSpawnLocFromPlayerLoc(player).add(0, 1, 0), player, type, amount);
player.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Spawned mob(s)!"));
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /mobspawn!"));
}
return CommandResult.success();
}
示例3: handleDamaged
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
private void handleDamaged() {
List<Instruction<DamagedCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> damagedProcessor = getDamagedProcessor();
damagedProcessor.add((condition, boss) -> {
DamageEntityEvent event = condition.getEvent();
new PlayerCombatParser() {
@Override
public void processPlayerAttack(Player attacker, Living defender) {
if (condition.getDamageSource().get() instanceof IndirectEntityDamageSource) {
attacker.sendMessage(Text.of(TextColors.RED, "Projectiles can't harm me... Mwahahaha!"));
event.setCancelled(true);
}
}
}.parse(event);
return Optional.empty();
});
}
示例4: onPlayerCombat
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
@Listener(order = Order.LATE)
public void onPlayerCombat(DamageEntityEvent event) {
Entity defendingEntity = event.getTargetEntity();
if (!(defendingEntity instanceof Living)) {
return;
}
Optional<Living> optAttackingEntity = getSource(event.getCause());
if (!optAttackingEntity.isPresent()) {
return;
}
Living attackingEntity = optAttackingEntity.get();
if (!applicabilityTest.test((Living) defendingEntity, null)) {
return;
}
if (cooldownHandler.canUseAbility(defendingEntity)) {
cooldownHandler.useAbility(defendingEntity);
} else {
return;
}
defensiveCluster.getNextAbilityToUse().run((Living) defendingEntity, attackingEntity, event);
}
示例5: 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;
}
示例6: castOn
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
@Override
public SkillResult castOn(Living target, IActiveCharacter source, ExtendedSkillInfo info) {
int intNodeValue = getIntNodeValue(info, SkillNodes.RADIUS);
float floatNodeValue = getFloatNodeValue(info, SkillNodes.DAMAGE);
long duration = getLongNodeValue(info, SkillNodes.DURATION);
for (Entity entity : target.getNearbyEntities(intNodeValue)) {
if (Utils.isLivingEntity(entity)) {
Living l = (Living) entity;
if (Utils.canDamage(source, l)) {
IEffectConsumer t = entityService.get(target);
StunEffect stunEffect = new StunEffect(t, duration);
effectService.addEffect(stunEffect, t, this);
if (floatNodeValue > 0) {
SkillDamageSourceBuilder build = new SkillDamageSourceBuilder();
build.fromSkill(this);
build.setCaster(source);
build.type(DamageTypes.ATTACK);
entity.damage(floatNodeValue, build.build());
}
}
}
}
return SkillResult.OK;
}
示例7: 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;
}
示例8: onBlockCollide
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
@Listener
public void onBlockCollide(CollideEvent.Impact event, @First Projectile projectile) {
ProjectileSource source = projectile.getShooter();
if (!(source instanceof Living)) {
return;
}
Living sourceEntity = (Living) source;
ItemStackSnapshot shootingItemStack = projectile.get(SHOOTING_ITEM_DATA_KEY).map(Optional::get).orElse(null);
if (!applicabilityTest.test(sourceEntity, shootingItemStack)) {
return;
}
if (cooldownHandler.canUseAbility(sourceEntity)) {
cooldownHandler.useAbility(sourceEntity);
} else {
return;
}
attackCluster.getNextAbilityToRun().run(sourceEntity, event.getImpactPoint());
}
示例9: onTick
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
@Override
public void onTick() {
super.onTick();
Vector3i chunkPosition = targetLocation.getChunkPosition();
Optional<Chunk> chunk = targetLocation.getExtent().getChunk(chunkPosition);
if (chunk.isPresent()) {
Chunk chunk1 = chunk.get();
Set<Entity> intersectingEntities = chunk1.getIntersectingEntities(aabb);
for (Entity intersectingEntity : intersectingEntities) {
if (Utils.isLivingEntity(intersectingEntity)) {
if (Utils.canDamage(character, (Living) intersectingEntities)) {
changeGravity(intersectingEntity);
}
} else if (intersectingEntity.getType() == EntityTypes.ITEM) {
changeGravity(intersectingEntity);
}
}
} else {
setDuration(0);
}
}
示例10: onTick
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
@Override
public void onTick() {
if (arrows != 0) {
Living entity = getConsumer().getEntity();
World world = entity.getWorld();
Vector3d rotation = entity.getRotation();
Vector3d direction = Quaterniond.fromAxesAnglesDeg(rotation.getX(), -rotation.getY(), rotation.getZ()).getDirection();
Entity arrow = world.createEntity(EntityTypes.TIPPED_ARROW,
entity.getLocation().getPosition()
.add(cos((entity.getRotation().getX() - 90) % 360) * 0.2,
1.8,
sin((entity.getRotation().getX() - 90) % 360) * 0.2));
Arrow sb = (Arrow) arrow;
sb.setShooter(entity);
world.spawnEntity(sb);
sb.offer(Keys.VELOCITY, direction.mul(3f));
arrows--;
} else {
setDuration(0); //remove the effect next effect scheduler phase
}
}
示例11: run
import org.spongepowered.api.entity.living.Living; //导入依赖的package包/类
@Override
public void run(Living owner, Living attacker, DamageEntityEvent event) {
notify(owner, Text.of(TextColors.YELLOW, "Your armor releases a burst of energy."));
notify(owner, Text.of(TextColors.YELLOW, "You are healed by an ancient force."));
final double attackDamage = event.getBaseDamage();
EntityHealthUtil.heal(owner, attackDamage);
getTargetEntities(owner).stream().filter(e -> e instanceof Living).forEach(e -> {
if (e.equals(owner)) {
return;
}
if (e.getType() == owner.getType()) {
EntityHealthUtil.heal((Living) e, attackDamage);
notify((Living) e, Text.of(TextColors.YELLOW, "You are healed by an ancient force."));
} else if (!(owner instanceof Player) || e instanceof Monster) {
e.setVelocity(new Vector3d(
Probability.getRangedRandom(-1.5, 1.5),
Probability.getRandom(2.5),
Probability.getRangedRandom(-1.5, 1.5)
));
e.offer(Keys.FIRE_TICKS, Probability.getRandom(20 * 60));
}
});
}
示例12: 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."));
}
示例13: 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."));
}
}
示例14: 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."));
}
示例15: 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."));
}