Package org.spout.api.geo.discrete

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


      layEgg();
    }
  }

  private void layEgg() {
    Point position = getOwner().getPhysics().getPosition();
    Item.drop(position, new ItemStack(VanillaMaterials.EGG, 1), Vector3f.ZERO);
    Float nextEgg = (float) (GenericMath.getRandom().nextInt(MINIMUM_EGG_BREEDING_TIME) + MINIMUM_EGG_BREEDING_TIME);
    getOwner().getData().put(VanillaData.TIME_TILL_EGG, nextEgg);
  }
View Full Code Here


      final WorldGenerator generator = world.getGenerator();
      boolean newWorld = world.getAge() <= 0;

      if (worldConfig.LOADED_SPAWN.getBoolean() || newWorld) {

        final Point spawn;

        // Grab safe spawn if newly created world and generator is vanilla generator, else get old one.
        if (newWorld && generator instanceof VanillaGenerator) {
          spawn = ((VanillaGenerator) generator).getSafeSpawn(world);
          world.setSpawnPoint(new Transform(spawn, Quaternionf.IDENTITY, Vector3f.ONE));
        } else {
          spawn = world.getSpawnPoint().getPosition();
        }

        // Start the protection for the spawn
        ((VanillaProtectionService) getEngine().getServiceManager().getRegistration(ProtectionService.class).getProvider()).addProtection(new SpawnProtection(world.getName() + " Spawn Protection", world, spawn, protectionRadius));

        // Chunks coords of the spawn
        int cx = spawn.getBlockX() >> Chunk.BLOCKS.BITS;
        int cz = spawn.getBlockZ() >> Chunk.BLOCKS.BITS;

        // Load or generate spawn area
        int effectiveRadius = newWorld ? (2 * radius) : radius;

        // Add observer to spawn to keep loaded if desired
View Full Code Here

import org.spout.api.render.effect.SnapshotMesh;

public class TallGrassOffsetEffect implements MeshEffect {
  @Override
  public void preMesh(SnapshotMesh mesh) {
    final Point pos = mesh.getPosition();
    long hash = pos.getFloorX() * 393443L
        ^ pos.getFloorY() * 96754111L
        ^ pos.getFloorZ() * 228329L;
    hash *= hash * (hash + 89249651343L);
    mesh.setPosition(pos.add(
        ((hash >> 16 & 0xF) / 15f - 0.5f) * 0.5f,
        ((hash >> 20 & 0xF) / 15f - 1) * 0.2f,
        ((hash >> 24 & 0xF) / 15f - 0.5f) * 0.5f));
  }
 
View Full Code Here

  public void onInteract(final EntityInteractEvent event) {
    if (event instanceof PlayerInteractEntityEvent) {
      final PlayerInteractEntityEvent pie = (PlayerInteractEntityEvent) event;
      switch (pie.getAction()) {
        case LEFT_CLICK:
          Point pos = getOwner().getPhysics().getPosition();
          Item.dropNaturally(pos, new ItemStack(VanillaMaterials.ITEM_FRAME, 1));
          if (material != null) {
            Item.dropNaturally(pos, new ItemStack(material, 1));
          }
          getOwner().remove();
View Full Code Here

    public void run() {
      if (!player.isOnline() || !weather.isRaining()) {
        return;
      }
      Random rand = GenericMath.getRandom();
      Point playerPos = player.getPhysics().getPosition();
      final int posX = GenericMath.floor(playerPos.getX());
      final int posY = GenericMath.floor(playerPos.getY());
      final int posZ = GenericMath.floor(playerPos.getZ());
      for (int tries = 0; tries < 10; tries++) {
        //pick a random chunk between -4, -4, to 4, 4 relative to the player's position
        int cx = (rand.nextBoolean() ? -1 : 1) * rand.nextInt(5);
        int cz = (rand.nextBoolean() ? -1 : 1) * rand.nextInt(5);

 
View Full Code Here

    }
  }

  public void strikePlayers(List<Player> toStrike) {
    for (Player player : toStrike) {
      Point playerPos = player.getPhysics().getPosition();
      final int posX = GenericMath.floor(playerPos.getX());
      final int posY = GenericMath.floor(playerPos.getY());
      final int posZ = GenericMath.floor(playerPos.getZ());
      for (int tries = 0; tries < 10; tries++) {
        //pick a random chunk between -4, -4, to 4, 4 relative to the player's position to strike at
        int cx = (ra.nextBoolean() ? -1 : 1) * ra.nextInt(5);
        int cz = (ra.nextBoolean() ? -1 : 1) * ra.nextInt(5);

        //pick random coords to try to strike at inside the chunk (0, 0) to (15, 15)
        int rx = ra.nextInt(16);
        int rz = ra.nextInt(16);

        //pick a offset from the player's y position to strike at (-15 - +15) of their position
        int offsetY = (ra.nextBoolean() ? -1 : 1) * ra.nextInt(15);

        int x = posX + cx * 16 + rx;
        int y = posY + offsetY;
        int z = posZ + cz * 16 + rz;

        if (weather.isRainingAt(x, y, z, false)) {
          int lightning = 1;
          //30% chance of extra lightning at the spot
          if (ra.nextInt(10) < 3) {
            lightning += ra.nextInt(MAX_LIGHTNING_BRANCHES);
          }
          for (int strikes = 0; strikes < lightning; strikes++) {
            float adjustX = 0.5F;
            float adjustY = 0.0F;
            float adjustZ = 0.5F;
            //if there are extra strikes, tweak their placement slightly
            if (strikes > 0) {
              adjustX += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(2);
              adjustY += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(8);
              adjustZ += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(2);
            }
            World world = getWorld();
            Point point = new Point(world, x + adjustX, y + adjustY, z + adjustZ);
            world.createAndSpawnEntity(point, LoadOption.NO_LOAD, Lightning.class);
            for (Player p : GeneralEffects.LIGHTNING_THUNDER.getNearbyPlayers(point, null, 600)) {
              double dist = p.getPhysics().getPosition().distanceSquared(point);
              float volume = (float) (10000F - Math.pow(dist, 0.73));
              if (volume > 0) {
View Full Code Here

    for (byte attempts = 0; attempts < 32; attempts++) {
      final int x = random.nextInt(256) - 127;
      final int z = random.nextInt(256) - 127;
      final int y = getHighestSolidBlock(world, x, z);
      if (y != -1) {
        return new Point(world, x, y + 0.5f, z);
      }
    }
    return new Point(world, 0, 80, 0);
  }
View Full Code Here

    }
    getOwner().getData().put(VanillaData.GROWTH_TICKS, newGrowthTicks);
  }

  private void eatGrass() {
    final Point position = getOwner().getPhysics().getPosition();
    final int x = position.getFloorX();
    final int y = position.getFloorY() - 1;
    final int z = position.getFloorZ();
    if (isBlockEatableTallGrass(x, y, z)) {
      getOwner().getWorld().setBlockMaterial(x, y, z, VanillaMaterials.AIR, (short) 0, new EntityCause(getOwner()));
      onGrassEaten();
    } else if (getOwner().getWorld().getBlockMaterial(x, y, z) == VanillaMaterials.GRASS) {
      getOwner().getWorld().setBlockMaterial(x, y, z, VanillaMaterials.DIRT, (short) 0, new EntityCause(getOwner()));
View Full Code Here

  @Permissible ("vanilla.command.debug")
  @Filter (PlayerFilter.class)
  public void targetHeight(Player player, CommandArguments args) throws CommandException {
    args.assertCompletelyParsed();

    Point pos = player.getPhysics().getPosition();

    int height = pos.getWorld().getSurfaceHeight(pos.getBlockX(), pos.getBlockZ());

    player.sendMessage("You are at " + pos.getBlockX() + ", " + pos.getBlockY() + ", " + pos.getBlockZ());
    player.sendMessage("Surface Height " + height + " " + (pos.getBlockY() - height) + " blocks below");
  }
View Full Code Here

    }
  }

  public boolean shouldEatGrass() {
    final Random random = getRandom();
    final Point position = getOwner().getPhysics().getPosition();
    final int x = position.getFloorX();
    final int y = position.getFloorY() - 1;
    final int z = position.getFloorZ();
    int maxInt;
    if (getOwner().getData().get(VanillaData.GROWTH_TICKS) < 24000) {
      maxInt = GRASS_CHANCE_AS_BABY;
    } else {
      maxInt = GRASS_CHANCE_AS_ADULT;
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.