Package org.spout.api.geo.discrete

Examples of org.spout.api.geo.discrete.Point


   * primary effect is not the same as the secondary effect. Note that in order for the secondary effect to be applied it must differ from the primary effect otherwise a buff will just be applied to
   * the primary effect.
   */
  public void doUpdate() {
    resetUpdateDelay();
    Point pos = getPoint();
    EntityEffectType primary = getPrimaryEffect();
    EntityEffectType secondary = getSecondaryEffect();
    if (getLevels() < 1 || primary == null || primary == EntityEffectType.NONE) {
      return;
    }

    for (Player player : pos.getWorld().getNearbyPlayers(pos, (int) getEffectRange())) {
      Effects effects = player.add(Effects.class);
      effects.add(new EntityEffect(primary, getPrimaryAmplifier(), getEffectDuration()));
      if (secondary != null && secondary != EntityEffectType.NONE && getLevels() == 4 && primary != secondary) {
        effects.add(new EntityEffect(secondary, getEffectDuration()));
      }
View Full Code Here


  /**
   * Attempts to spawn the amount of entities specified by {@link #getSpawnCount()} within the range specified by {@link #getSpawnRange()} and resets the spawn delay.
   */
  public void doSpawn() {
    Point pos = getPoint();
    resetSpawnDelay();
    for (int i = 0; i < getSpawnCount(); i++) {
      float range = getSpawnRange();
      float x = pos.getX() + (random.nextFloat() - random.nextFloat()) * range;
      float y = pos.getY() + random.nextInt(3) - 1;
      float z = pos.getZ() + (random.nextFloat() - random.nextFloat()) * range;
      Point p = new Point(pos.getWorld(), x, y, z);
      if (p.getBlock().getMaterial().isMaterial(VanillaMaterials.AIR) && canSpawn()) {
        p.getWorld().createAndSpawnEntity(p, LoadOption.LOAD_ONLY, getCreatureType().getComponentType());
      }
    }
  }
View Full Code Here

      if (Spout.debugMode()) {
        Spout.getLogger().info("Statement: " + statement);
        Spout.getLogger().info("Corresponding Filter: " + filter);
      }

      final Point center = new Point(getBlock().getWorld(), filter.x, filter.y, filter.z);
      final char target = statement.charAt(1);
      final List<Player> allPlayers = Arrays.asList(((Server) Spout.getEngine()).getOnlinePlayers());

      switch (target) {

        case NEAREST_PLAYER_CHAR:
          // find the closest suitable player
          List<Player> nearbyPlayers = center.getWorld().getNearbyPlayers(center, filter.maxRadius);
          Player nearbyPlayer = filter.findPlayer(nearbyPlayers);
          if (nearbyPlayer == null) {
            return;
          }
          cmds.add(cmd.replace(statement, nearbyPlayer.getName()));
View Full Code Here

      }
      return filteredPlayers;
    }

    public boolean accept(Player p) {
      Point center = new Point(block.getWorld(), x, y, z);
      int distance = Math.round((float) p.getPhysics().getPosition().distance(center)); // the distance from the cmd block

      // get various principles (these all default to true if not specified)
      boolean closeEnough = (minRadius == -1 || distance >= minRadius) && (maxRadius == -1 || distance <= maxRadius);
      boolean correctMode = mode == null || mode.equals(p.get(Human.class).getGameMode());
View Full Code Here

    }
  }

  private void destroy() {
    List<ItemStack> drops = getOwner().get(DeathDrops.class).getDrops();
    Point entityPosition = getOwner().getPhysics().getPosition();
    for (ItemStack stack : drops) {
      if (stack != null) {
        Item.dropNaturally(entityPosition, stack);
      }
    }
View Full Code Here

  @Override
  public void onCollided(EntityCollideEvent event) {
    if (event instanceof EntityCollideBlockEvent) {
      final EntityCollideBlockEvent collideBlockEvent = (EntityCollideBlockEvent) event;
      final Point point = new Point(collideBlockEvent.getContactInfo().getNormal(), getOwner().getWorld());
      final int x = point.getBlockX();
      final int y = point.getBlockX();
      final int z = point.getBlockX();
      final Block translated = getOwner().getWorld().getBlock(x, y, z).translate(BlockFace.TOP);
      final BlockMaterial material = translated.getMaterial();
      if (material.isPlacementObstacle()) {
        Item.dropNaturally(point, new ItemStack(getMaterial(), 1));
      } else {
View Full Code Here

  }

  @Override
  public void onTick(float dt) {
    super.onTick(dt);
    final Point position = getOwner().getPhysics().getPosition();
    setInWater(position.getBlock().getMaterial() instanceof Water);
  }
View Full Code Here

   * @param player true to only find players, false if it doesn't matter
   * @param range range to scan for
   * @return Entity the Entity found or null if none found
   */
  public Entity findAndFollow(boolean player, int range) {
    final Point point = getOwner().getPhysics().getPosition();
    List potentialToFollow;
    if (player) {
      potentialToFollow = point.getWorld().getNearbyPlayers(getOwner(), range);
    } else {
      potentialToFollow = point.getWorld().getNearbyEntities(getOwner(), range);
    }
    //None found :'(...return null.
    if (potentialToFollow.size() == 0) {
      return null;
    }
View Full Code Here

    DeathDrops deathDropsComp = getOwner().get(DeathDrops.class);
    if (deathDropsComp == null) {
      return;
    }
    List<ItemStack> drops = deathDropsComp.getDrops();
    Point entityPosition = getOwner().getPhysics().getPosition();
    for (ItemStack stack : drops) {
      if (stack != null) {
        Item.dropNaturally(entityPosition, stack);
      }
    }
View Full Code Here

    final int x = 16 - random.nextInt(32);
    final int z = 16 - random.nextInt(32);
    int y = VanillaPlayerNetworkComponent.WORLD_HEIGHT - 1;
    for (; world.getBlockMaterial(x, y, z).getShape() == null; y--) {
    }
    return new Point(world, x, y + 1.5f, z);
  }
View Full Code Here

TOP

Related Classes of org.spout.api.geo.discrete.Point

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.