Package org.spout.vanilla.component.block.material

Examples of org.spout.vanilla.component.block.material.Sign


  @Override
  public abstract boolean canSupport(BlockMaterial material, BlockFace face);

  @Override
  public ProtocolEvent getUpdate(World world, int x, int y, int z, BlockComponentOwner owner) {
    Sign sign = owner.get(Sign.class);
    if (sign != null) {
      return new SignUpdateEvent(sign, sign.getText(), null);
    }
    return null;
  }
View Full Code Here


    event.getMessages().add(new EntityMetadataMessage(event.getEntity().getId(), event.getParameters()));
  }

  @EventHandler
  public void onSignUpdate(SignUpdateEvent event) {
    Sign sign = event.getSign();
    event.getMessages().add(new SignMessage(sign.getOwner().getX(), sign.getOwner().getY(), sign.getOwner().getZ(), event.getLines(), getRepositionManager()));
  }
View Full Code Here

    int x = rmInverse.convertX(message.getX());
    int y = rmInverse.convertY(message.getY());
    int z = rmInverse.convertZ(message.getZ());

    Sign sign = player.getWorld().getBlock(x, y, z).get(Sign.class);
    if (sign == null) {
      return;
    }

    String[] text = message.getMessage();
    if (text.length != 4) {
      return;
    }

    sign.setText(text, new PlayerCause(player));
  }
View Full Code Here

    int x = rm.convertX(message.getX());
    int y = rm.convertY(message.getY());
    int z = rm.convertZ(message.getZ());

    Sign sign = player.getWorld().getBlock(x, y, z).get(Sign.class);
    if (sign == null) {
      return;
    }

    String[] text = message.getMessage();
    if (text.length != 4) {
      return;
    }

    sign.setText(text, new PlayerCause(player));
  }
View Full Code Here

        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) {
                session.send(new SignMessage(block.getX(), block.getY(), block.getZ(), sign.getText(), player.getNetwork().getRepositionManager()));
              }
            }
          } else {
            // Perform interactions
            if (heldItem == null) {
              // interacting using fist
            } else if (!isInteractable) {
              // interacting with nothing using item
              heldItem.getMaterial().onInteract(player, Action.LEFT_CLICK);
            } else {
              // interacting with block using item
              heldItem.getMaterial().onInteract(player, block, Action.LEFT_CLICK, clickedFace);
            }

            if (isInteractable) {
              Block neigh = block.translate(clickedFace);
              boolean fire = neigh.getMaterial().equals(VanillaMaterials.FIRE);
              if (fire) {
                // put out fire
                if (VanillaMaterials.FIRE.onDestroy(neigh, new PlayerBreakCause(player, neigh))) {
                  GeneralEffects.RANDOM_FIZZ.playGlobal(block.getPosition());
                }
              } else if (human.isSurvival() && blockMaterial.getHardness() != 0.0f) {
                ItemStack currentItem = PlayerUtil.getHeldSlot(player).get();
                if (currentItem != null) {
                  player.get(Digging.class).startDigging(new Point(w, x, y, z), currentItem.getMaterial());
                } else {
                  player.get(Digging.class).startDigging(new Point(w, x, y, z), VanillaMaterials.AIR);
                }
              } else {
                // insta-break
                if (breakBlock(blockMaterial, block, human, session)) {
                  GeneralEffects.BREAKBLOCK.playGlobal(block.getPosition(), blockMaterial, player);
                }
              }
            }
          }
        }
        break;
      case PlayerDiggingMessage.STATE_CANCEL_DIGGING:
        if (!isProtected(player, rm, x, y, z, block, minecraftID)) {
          player.get(Digging.class).stopDigging(new Point(w, x, y, z), false);
        }
        break;
      case PlayerDiggingMessage.STATE_DONE_DIGGING:
        if (!isProtected(player, rm, x, y, z, block, minecraftID)) {
          Digging diggingComponent = player.get(Digging.class);

          if (!diggingComponent.stopDigging(new Point(w, x, y, z), true) || !isInteractable) {
            if (!diggingComponent.isDigging()) {
              session.send(new BlockChangeMessage(block, player.getNetwork().getRepositionManager()));
              Sign sign = block.get(Sign.class);
              if (sign != null) {
                session.send(new SignMessage(block.getX(), block.getY(), block.getZ(), sign.getText(), player.getNetwork().getRepositionManager()));
              }
            }
            return;
          }
View Full Code Here

      heldItem.getMaterial().getItemFlags(heldItem, flags);
    }
    if (!blockMaterial.destroy(block, flags, new PlayerBreakCause((Player) human.getOwner(), block))) {
      RepositionManager rm = session.getPlayer().getNetwork().getRepositionManager();
      session.send(new BlockChangeMessage(block, rm));
      Sign sign = block.get(Sign.class);
      if (sign != null) {
        session.send(new SignMessage(block.getX(), block.getY(), block.getZ(), sign.getText(), rm));
      }
      return false;
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.component.block.material.Sign

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.