Package org.spout.api.geo.discrete

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


            // undoPlacement(player, clickedBlock, alterBlock);
            // return;
            // }

            // For now: simple distance checking
            Point tpos = placedBlock.getPosition();
            if (player.getPhysics().getPosition().distance(tpos) < 0.6) {
              refreshClient(player, clickedBlock, clickedFace, rm);
              return;
            }
            EntityHead head = player.get(EntityHead.class);
View Full Code Here


        // If we haven't logged in before, we want to set all abilities to the default gamemode
        human.setGamemode(gamemode, false);
      }
    } else if (message.getStatus() == PlayerStatusMessage.RESPAWN) {
      Player player = session.getPlayer();
      Point point = player.getWorld().getSpawnPoint().getPosition();
      if (PlayerRespawnEvent.getHandlerList().getRegisteredListeners().length > 0) {
        PlayerRespawnEvent event = server.getEventManager().callEvent(new PlayerRespawnEvent(player, point));

        if (event.isCancelled()) {
          return;
View Full Code Here

          }
        }

        // Exhaustion

        final Point pos = getOwner().getPhysics().getPosition();
        if (lastPos == null) {
          lastPos = pos;
          return;
        }

        float exhaustion = getExhaustion();
        final World world = pos.getWorld();

        // Did not move 1 block pos
        if (lastPos.getBlockX() != pos.getBlockX() || lastPos.getBlockY() != pos.getBlockY() || lastPos.getBlockZ() != pos.getBlockZ()) {
          int dx = lastPos.getBlockX() - pos.getBlockX();
          int dy = lastPos.getBlockY() - pos.getBlockY();
          int dz = lastPos.getBlockZ() - pos.getBlockZ();

          final boolean sprinting = human.isSprinting();
          final boolean jumping = human.isJumping();
          if (world.getBlock(pos).getMaterial() instanceof Water && world.getBlock(lastPos).getMaterial() instanceof Water) {
            // swimming            ;
View Full Code Here

    this.title = title;
  }

  public EntityPaintingMessage(Painting painting, RepositionManager rm) {
    super(painting.getOwner());
    Point pos = painting.getOwner().getPhysics().getPosition();
    x = rm.convertX(pos.getBlockX());
    y = rm.convertY(pos.getBlockY());
    z = rm.convertZ(pos.getBlockZ());
    direction = painting.getNativeFace();
    title = painting.getType().getName();
  }
View Full Code Here

  }

  @Override
  public void onIgnite(Block block, Cause<?> cause) {
    // spawn a primed TntBlock
    Point pos = block.getPosition();
    World world = pos.getWorld();
    Tnt tnt = world.createEntity(pos, Tnt.class).add(Tnt.class);
    world.spawnEntity(tnt.getOwner());
    block.setMaterial(VanillaMaterials.AIR, cause);
  }
View Full Code Here

        mineItem.spawnEntity(facingBlock, Vector3f.ZERO);
        slot.addAmount(-1);
        return true;
      }
    } else if (item.getMaterial() instanceof BoatItem) {
      Point placePos;
      if (facingBlock.getMaterial() instanceof Water) {
        placePos = facingBlock.getPosition().add(.5f, 1f, .5f);
      } else if (facingBlock.getMaterial().equals(VanillaMaterials.AIR) && facingBlock.translate(BlockFace.BOTTOM).getMaterial() instanceof Water) {
        placePos = facingBlock.getPosition().add(.5f, 0f, .5f);
      } else {
        return false;
      }
      Boat boat = ((BoatItem) item.getMaterial()).spawnEntity(placePos);
      block.getWorld().spawnEntity(boat.getOwner());
      slot.addAmount(-1);
      return true;
    } else {
      // Try to shoot the item selected if we can't do anything else with it
      final Random rand = GenericMath.getRandom();
      Vector3f direction = this.getFacing(block).getOffset();

      // Calculate position to shoot from
      Point position = block.getPosition().add(direction.mul(0.6));
      VanillaEntityComponent toLaunch = null;

      // Calculate shooting velocity using facing direction
      Vector3f velocity = direction.mul(rand.nextDouble() * 0.1 + 0.2);
      // Set velocity y to above (0.2)
      velocity = velocity.mul(1.0, 0.0, 1.0).add(0.0, 0.2, 0.0);
      velocity = velocity.add(0.045 * rand.nextGaussian(), 0.045 * rand.nextGaussian(), 0.045 * rand.nextGaussian());

      Effect shootEffect;
      Material material = item.getMaterial();
      //TODO: Implement the following 'special' shoot cases:
      // - eggs, arrows, fireballs and snowballs
      // - potions, exp. bottles, monster eggs
      // - armor,

      if (material.equals(VanillaMaterials.ARROW)) {
        shootEffect = GeneralEffects.RANDOM_BOW;
        toLaunch = new Arrow();
      } else if (material.equals(VanillaMaterials.EGG)) {
        shootEffect = GeneralEffects.RANDOM_BOW;
        //TODO: Spawn
      } else if (material.equals(VanillaMaterials.SNOWBALL)) {
        shootEffect = GeneralEffects.RANDOM_BOW;
        //TODO: Spawn
      } else if (material instanceof PotionItem && ((PotionItem) material).isSplash()) {
        shootEffect = GeneralEffects.RANDOM_BOW;
        //TODO: Spawn
      } else if (material.equals(VanillaMaterials.BOTTLE_O_ENCHANTING)) {
        shootEffect = GeneralEffects.RANDOM_BOW;
        //TODO: Spawn
      } else if (material instanceof SpawnEgg) {
        shootEffect = GeneralEffects.RANDOM_BOW;
        //TODO: Spawn
      } else if (material.equals(VanillaMaterials.FIRE_CHARGE)) {
        shootEffect = GeneralEffects.SHOOT_FIREBALL;
        //TODO: Spawn
      } else {
        shootEffect = GeneralEffects.RANDOM_CLICK1;
        position = position.sub(0.0, 0.3, 0.0);
        toLaunch = new Item();
        ((Item) toLaunch).setItemStack(item);
      }

      if (toLaunch != null) {
View Full Code Here

            held.addData(1);
          }
        }

        // Handle the creation of portals
        Point pos = target.translate(BlockFace.BOTTOM).getPosition();
        VanillaObjects.NETHER_PORTAL.setActive(pos.getWorld(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), true);
      }
    }
  }
View Full Code Here

  public EntityObjectMessage(Entity entity, byte type, int throwerId, RepositionManager rm) {
    super(entity);
    this.type = type;
    this.throwerId = throwerId;
    Transform transform = entity.getPhysics().getTransform();
    Point pos = transform.getPosition();

    double p = 32d;
    x = rm.convertX((int) Math.floor(pos.getX() * p));
    y = rm.convertY((int) Math.floor(pos.getY() * p));
    z = rm.convertZ((int) Math.floor(pos.getZ() * p));

    double v = 3.9d;
    Vector3f factor = new Vector3f(v, v, v);

    Vector3f velocity;
View Full Code Here

  @Override
  public boolean onDestroy(Block block, Cause<?> cause) {
    BrewingStand brewingStand = block.get(BrewingStand.class);
    // Drop items
    Inventory inventory = brewingStand.getInventory();
    Point position = block.getPosition();
    for (ItemStack item : inventory) {
      if (item == null) {
        continue;
      }
      Item.dropNaturally(position, item);
View Full Code Here

public class PlayerSpawnHandler extends MessageHandler<PlayerSpawnMessage> {
  @Override
  public void handleClient(ClientSession session, PlayerSpawnMessage message) {
    World w = session.getEngine().getDefaultWorld();
    final Point pos = new Point(w, message.getX(), message.getY(), message.getZ());

    // Create a new Player Entity with a Human Entity Component
    Entity entity = w.createEntity(pos, Human.class);
    entity.setSavable(true);
    entity.add(Human.class).setName(message.getName());
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.