Examples of PlayerInteractBlockEvent


Examples of org.spout.api.event.player.PlayerInteractBlockEvent

  @Override
  public void onInteract(final EntityInteractEvent event) {
    super.onInteract(event);
    if (event instanceof PlayerInteractBlockEvent) {
      final PlayerInteractBlockEvent pib = (PlayerInteractBlockEvent) event;
      final Player player = (Player) pib.getEntity();
      switch (pib.getAction()) {
        case RIGHT_CLICK:
          if (open(player)) {
            viewers.add(player);
          }
      }
View Full Code Here

Examples of org.spout.api.event.player.PlayerInteractBlockEvent

    // TODO VanillaPlayerInteractBlockEvent and add in Results to it (to
    // more indepthly take away durability).
    switch (state) {
      case PlayerDiggingMessage.STATE_START_DIGGING:
        if (!isProtected(player, rm, x, y, z, block, minecraftID)) {
          final PlayerInteractBlockEvent event = new PlayerInteractBlockEvent(player, block, point, clickedFace, Action.LEFT_CLICK);
          if (player.getEngine().getEventManager().callEvent(event).isCancelled()) {
            if (human.isCreative() || blockMaterial.getHardness() == 0.0f) {
              session.send(new BlockChangeMessage(block, player.getNetwork().getRepositionManager()));
              Sign sign = block.get(Sign.class);
              if (sign != null) {
View Full Code Here

Examples of org.spout.api.event.player.PlayerInteractBlockEvent

  @Override
  public void onInteractBy(Entity entity, Block block, Action type, BlockFace clickedFace) {
    EntityInteractBlockEvent event;
    if (entity instanceof Player) {
      event = new PlayerInteractBlockEvent((Player) entity, block, block.getPosition(), clickedFace, type);
    } else {
      event = new EntityInteractBlockEvent(entity, block, block.getPosition(), clickedFace);
    }
    if (Spout.getEventManager().callEvent(event).isCancelled()) {
      return;
View Full Code Here

Examples of org.spout.api.event.player.PlayerInteractBlockEvent

      hunger.setEating(true, currentSlot);
      return;
    }
    if (clickedFace == BlockFace.THIS) {
      // Right clicked air with an item.
      PlayerInteractBlockEvent event = Spout.getEventManager().callEvent(new PlayerInteractBlockEvent(player, null, null, clickedFace, Action.RIGHT_CLICK));

      // May have been changed by the event
      holding = currentSlot.get();
      holdingMat = holding == null ? null : holding.getMaterial();

      if (holdingMat != null) {
        holdingMat.onInteract(player, Action.RIGHT_CLICK);
      }
    } else {
      // TODO: Validate the x/y/z coordinates of the message to check if it is in range of the player
      // This is an anti-hack requirement (else hackers can load far-away chunks and crash the server)

      // Get clicked block and validated face against it was placed
      final Block clickedBlock = world.getBlock(message.getX(), message.getY(), message.getZ());
      final BlockMaterial clickedMaterial = clickedBlock.getMaterial();

      // Perform interaction event
      PlayerInteractBlockEvent interactEvent = Spout.getEventManager().callEvent(new PlayerInteractBlockEvent(player, clickedBlock, clickedBlock.getPosition(), clickedFace, Action.RIGHT_CLICK));

      // May have been changed by the event
      holding = currentSlot.get();
      holdingMat = holding == null ? null : holding.getMaterial();

      // check if the interaction was cancelled by the event
      if (interactEvent.isCancelled()) {
        refreshClient(player, clickedBlock, clickedFace, rm);
        return;
      }
      if (holdingMat != null) {
        holdingMat.onInteract(player, clickedBlock, Action.RIGHT_CLICK, clickedFace);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.