/** * Constructs the BlockIterator. * * @param entity Information from the entity is used to set up the trace * @param maxDistance This is the maximum distance in blocks for the * trace. Setting this value above 140 may lead to problems with * unloaded chunks. A value of 0 indicates no limit */ public BlockIterator(LivingEntity entity, int maxDistance) { this(entity.getLocation(), entity.getEyeHeight(), maxDistance); }
/** * Gets the location at which the creature is spawning. * * @return The location at which the creature is spawning */ public Location getLocation() { return getEntity().getLocation(); }
/** * Process teleportation when collide with an entity. * * @param entity the eneity that the ender pearl collides with */ @Override public void collide(LivingEntity entity) { ProjectileSource source = getShooter(); // the entity receives fake damage. if (source instanceof Entity) { entity.damage(0, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE); } else { entity.damage(0, EntityDamageEvent.DamageCause.PROJECTILE); } collide(entity.getLocation().getBlock()); }
/** * Process random spawn chicks when collide with a living entity. * * @param entity the eneity that the egg collides with */ @Override public void collide(LivingEntity entity) { ProjectileSource source = getShooter(); // the entity receives fake damage. if (entity instanceof Entity) { entity.damage(0, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE); } else { entity.damage(0, EntityDamageEvent.DamageCause.PROJECTILE); } collide(entity.getLocation().getBlock()); }
.get(ThreadLocalRandom.current().nextInt(livingEntities.size())); Vector newTarget = entity.getLocation().toVector(); x = newTarget.getBlockX(); z = newTarget.getBlockZ();
targetLocationTest1 = (player.getLocation().getBlockX() == targetLocation.getX() && player.getLocation().getBlockY() == targetLocation.getY() && player.getLocation().getBlockZ() == targetLocation.getZ()); targetLocationTest2 = (player.getEyeLocation().getBlockX() == targetLocation.getX() && player.getEyeLocation().getBlockY() == targetLocation.getY()
setVelocity(velocity); } else { Vector direction = boostedEntity.getLocation().getDirection(); Vector velocity = boostedEntity.getVelocity(); this.setVelocity(velocity); Location location = boostedEntity.getLocation().add(velocity); if (boostedEntity instanceof GlowEntity) { ((GlowEntity) boostedEntity).setRawLocation(location, false);
@Override public Location getLocation() { if (this.targetEntity != null) { return this.targetEntity.getLocation(); } else if (this.player != null) { return this.player.getLocation(); } return null; }
/** * Constructs the BlockIterator. * * @param entity Information from the entity is used to set up the trace * @param maxDistance This is the maximum distance in blocks for the * trace. Setting this value above 140 may lead to problems with * unloaded chunks. A value of 0 indicates no limit */ public BlockIterator(LivingEntity entity, int maxDistance) { this(entity.getLocation(), entity.getEyeHeight(), maxDistance); }
public static String handleEntityPlaceHolder(LivingEntity e, String cmd) { cmd = cmd.replaceAll("\\{entity}", e.getName()); cmd = cmd.replaceAll("\\{entity\\.uuid}", e.getUniqueId().toString()); cmd = cmd.replaceAll("\\{entity\\.x}", Float.toString(e.getLocation().getBlockX())); cmd = cmd.replaceAll("\\{entity\\.y}", Float.toString(e.getLocation().getBlockY())); cmd = cmd.replaceAll("\\{entity\\.z}", Float.toString(e.getLocation().getBlockZ())); cmd = cmd.replaceAll("\\{entity\\.yaw}", Float.toString(90 + e.getEyeLocation().getYaw())); cmd = cmd.replaceAll("\\{entity\\.pitch}", Float.toString(-e.getEyeLocation().getPitch())); return cmd; }
@Override public PowerResult<Double> hit(Player player, ItemStack stack, LivingEntity entity, double damage, EntityDamageByEntityEvent event) { Location location = entity.getLocation(); return fire(player, stack, location).with(damage); }
@Override public void execute(Arena arena, MABoss boss) { LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM); if (target == null) return; Location loc = target.getLocation(); loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270)); target.teleport(loc); } }
public void apply(LivingEntity target) { Player owner = myPet.getOwner().getPlayer(); isStriking = true; Location loc = target.getLocation(); MyPetApi.getPlatformHelper().strikeLightning(loc, 32); for (Entity entity : myPet.getEntity().get().getNearbyEntities(1.5, 1.5, 1.5)) { if (entity instanceof LivingEntity && entity != owner) { ((LivingEntity) entity).damage(damage.getValue().doubleValue(), myPet.getEntity().get()); } } isStriking = false; }
@Override public void execute(Arena arena, MABoss boss) { LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM); if (target == null) return; Location bLoc = boss.getEntity().getLocation(); Location loc = target.getLocation(); Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ()); target.setVelocity(v.normalize().setY(0.8)); } }
@Override public PowerResult<Double> hit(Player player, ItemStack stack, LivingEntity entity, double damage, EntityDamageByEntityEvent event) { Location location = entity.getLocation(); Location start = player.getLocation(); if (start.distanceSquared(location) >= distance * distance) { player.sendMessage(I18n.format("message.too.far")); return PowerResult.noop(); } return fire(player, stack, location).with(damage); }
@EventHandler(ignoreCancelled = true) public void onEntityDeath(EntityDeathEvent event) { if (event.getDroppedExp() > 0) { if (Events.fireAndTestCancel(new SpawnEntityEvent(event, create(event.getEntity()), event.getEntity().getLocation(), EntityType.EXPERIENCE_ORB))) { event.setDroppedExp(0); } } }
@Override public void run() { if (livingEntity.isValid()) { Location location = livingEntity.getLocation(); location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F); ParticleEffectUtils.playCallOfTheWildEffect(livingEntity); CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity); } TamingManager.removeFromTracker(this); this.cancel(); }
@Override public boolean onHit(EntityDamageByEntityEvent e, LivingEntity n) { if (SlimefunManager.isItemSimiliar(Variables.arrows.get(e.getDamager().getUniqueId()), SlimefunItems.ICY_BOW, true)) { n.getWorld().playEffect(n.getLocation(), Effect.STEP_SOUND, Material.ICE); n.getWorld().playEffect(n.getEyeLocation(), Effect.STEP_SOUND, Material.ICE); n.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 10)); n.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20 * 2, -10)); return true; } else return false; } });
@Override public void execute(Arena arena, MABoss boss) { Location bLoc = boss.getEntity().getLocation(); for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) { Location loc = p.getLocation(); Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ()); p.setVelocity(v.normalize().setY(0.8)); } } }
@Override public void execute(Arena arena, MABoss boss) { Location bLoc = boss.getEntity().getLocation(); for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) { Location loc = p.getLocation(); Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ()); p.setVelocity(v.normalize().setY(0.8)); } } }