Package simpleserver.config.data.Chests

Examples of simpleserver.config.data.Chests.Chest


              break;
          }

          Coordinate targetBlock = new Coordinate(xPosition, yPosition, zPosition, player);

          Chest adjacentChest = server.data.chests.adjacentChest(targetBlock);

          if (adjacentChest != null && !adjacentChest.isOpen() && !adjacentChest.ownedBy(player)) {
            player.addTMessage(Color.RED, "The adjacent chest is locked!");
            writePacket = false;
            drop = true;
          } else {
            player.placingChest(targetBlock);
          }
        }

        if (writePacket) {
          write(packetId);
          write(x);
          write(y);
          write(z);
          write(direction);
          write(dropItem);

          if (dropItem != -1) {
            write(itemCount);
            write(uses);
            if (data != null) {
              write((short) data.length);
              out.write(data);
            } else {
              write((short) -1);
            }

            if (dropItem <= 94 && direction >= 0) {
              player.placedBlock();
            }
          }
          write(blockX);
          write(blockY);
          write(blockZ);

          player.openingChest(coordinate);

        } else if (drop) {
          // Drop the item in hand. This keeps the client state in-sync with the
          // server. This generally prevents empty-hand clicks by the client
          // from placing blocks the server thinks the client has in hand.
          write((byte) 0x0e);
          write((byte) 0x04);
          write(x);
          write(y);
          write(z);
          write(direction);
        }

        break;
      case 0x10: // Holding Change
        write(packetId);
        copyNBytes(2);
        break;
      case 0x11: // Use Bed
        write(packetId);
        copyNBytes(14);
        break;
      case 0x12: // Animation
        write(packetId);
        copyNBytes(5);
        break;
      case 0x13: // Entity Action
        write(packetId);
        write(in.readInt());
        write(in.readByte());
        write(in.readInt());
        break;
      case 0x14: // Named Entity Spawn
        int eid = in.readInt();
        name = readUTF16();
        if (!server.bots.ninja(name)) {
          write(packetId);
          write(eid);
          write(name);
          copyNBytes(16);
          copyUnknownBlob();
        } else {
          skipNBytes(16);
          skipUnknownBlob();
        }
        break;
      case 0x16: // Collect Item
        write(packetId);
        copyNBytes(8);
        break;
      case 0x17: // Add Object/Vehicle
        write(packetId);
        write(in.readInt());
        write(in.readByte());
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        write(in.readByte());
        write(in.readByte());
        int flag = in.readInt();
        write(flag);
        if (flag > 0) {
          write(in.readShort());
          write(in.readShort());
          write(in.readShort());
        }
        break;
      case 0x18: // Mob Spawn
        write(packetId);
        write(in.readInt());
        write(in.readByte());
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        write(in.readByte());
        write(in.readByte());
        write(in.readByte());
        write(in.readShort());
        write(in.readShort());
        write(in.readShort());

        copyUnknownBlob();
        break;
      case 0x19: // Entity: Painting
        write(packetId);
        write(in.readInt());
        write(readUTF16());
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        break;
      case 0x1a: // Experience Orb
        write(packetId);
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        write(in.readShort());
        break;
      case 0x1b: // Steer Vehicle
        write(packetId);
        write(in.readFloat());
        write(in.readFloat());
        write(in.readBoolean());
        write(in.readBoolean());
        break;
      case 0x1c: // Entity Velocity
        write(packetId);
        copyNBytes(10);
        break;
      case 0x1d: // Destroy Entity
        write(packetId);
        byte destoryCount = write(in.readByte());
        if (destoryCount > 0) {
          copyNBytes(destoryCount * 4);
        }
        break;
      case 0x1e: // Entity
        write(packetId);
        copyNBytes(4);
        break;
      case 0x1f: // Entity Relative Move
        write(packetId);
        copyNBytes(7);
        break;
      case 0x20: // Entity Look
        write(packetId);
        copyNBytes(6);
        break;
      case 0x21: // Entity Look and Relative Move
        write(packetId);
        copyNBytes(9);
        break;
      case 0x22: // Entity Teleport
        write(packetId);
        copyNBytes(18);
        break;
      case 0x23: // Entitiy Look
        write(packetId);
        write(in.readInt());
        write(in.readByte());
        break;
      case 0x26: // Entity Status
        write(packetId);
        copyNBytes(5);
        break;
      case 0x27: // Attach Entity
        write(packetId);
        write(in.readInt());
        write(in.readInt());
        write(in.readBoolean());
        break;
      case 0x28: // Entity Metadata
        write(packetId);
        write(in.readInt());

        copyUnknownBlob();
        break;
      case 0x29: // Entity Effect
        write(packetId);
        write(in.readInt());
        write(in.readByte());
        write(in.readByte());
        write(in.readShort());
        break;
      case 0x2a: // Remove Entity Effect
        write(packetId);
        write(in.readInt());
        write(in.readByte());
        break;
      case 0x2b: // Experience
        write(packetId);
        player.updateExperience(write(in.readFloat()), write(in.readShort()), write(in.readShort()));
        break;
      case 0x2c: // Entity Properties
        write(packetId);
        write(in.readInt());
        int properties_count = in.readInt();
        short list_length = 0;
        write(properties_count);

        // loop for every property key/value pair
        for (int i = 0; i < properties_count; i++) {
          write(readUTF16());
          write(in.readDouble());

          // grab list elements
          list_length = in.readShort();
          write(list_length);
          if (list_length > 0) {
            for (int k = 0; k < list_length; k++) {
              write(in.readLong());
              write(in.readLong());
              write(in.readDouble());
              write(in.readByte());
            }
          }
        }
        break;
      case 0x33: // Map Chunk
        write(packetId);
        write(in.readInt());
        write(in.readInt());
        write(in.readBoolean());
        write(in.readShort());
        write(in.readShort());
        copyNBytes(write(in.readInt()));
        break;
      case 0x34: // Multi Block Change
        write(packetId);
        write(in.readInt());
        write(in.readInt());
        write(in.readShort());
        copyNBytes(write(in.readInt()));
        break;
      case 0x35: // Block Change
        write(packetId);
        x = in.readInt();
        y = in.readByte();
        z = in.readInt();
        short blockType = in.readShort();
        byte metadata = in.readByte();
        coordinate = new Coordinate(x, y, z, player);

        if (blockType == 54 && player.placedChest(coordinate)) {
          lockChest(coordinate);
          player.placingChest(null);
        }

        write(x);
        write(y);
        write(z);
        write(blockType);
        write(metadata);

        break;
      case 0x36: // Block Action
        write(packetId);
        copyNBytes(14);
        break;
      case 0x37: // Mining progress
        write(packetId);
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        write(in.readByte());
        break;
      case 0x38: // Chunk Bulk
        write(packetId);
        short chunkCount = in.readShort();
        int dataLength = in.readInt();
        write(chunkCount);
        write(dataLength);
        write(in.readBoolean());
        copyNBytes(chunkCount * 12 + dataLength);
        break;
      case 0x3c: // Explosion
        write(packetId);
        copyNBytes(28);
        int recordCount = in.readInt();
        write(recordCount);
        copyNBytes(recordCount * 3);
        write(in.readFloat());
        write(in.readFloat());
        write(in.readFloat());
        break;
      case 0x3d: // Sound/Particle Effect
        write(packetId);
        write(in.readInt());
        write(in.readInt());
        write(in.readByte());
        write(in.readInt());
        write(in.readInt());
        write(in.readByte());
        break;
      case 0x3e: // Named Sound/Particle Effect
        write(packetId);
        write(readUTF16());
        write(in.readInt());
        write(in.readInt());
        write(in.readInt());
        write(in.readFloat());
        write(in.readByte());
        break;
      case 0x3f: // particle
        write(packetId);
        write(readUTF16()); // name of particle
        write(in.readFloat()); // x
        write(in.readFloat()); // y
        write(in.readFloat()); // z
        write(in.readFloat()); // offset x
        write(in.readFloat()); // offset y
        write(in.readFloat()); // offset z
        write(in.readFloat()); // particle speed
        write(in.readInt()); // num of particles
        break;
      case 0x46: // New/Invalid State
        write(packetId);
        write(in.readByte());
        write(in.readByte());
        break;
      case 0x47: // Thunderbolt
        write(packetId);
        copyNBytes(17);
        break;
      case 0x64: // Open Window
        boolean allow = true;
        byte id = in.readByte();
        byte invtype = in.readByte();
        String title = readUTF16();
        byte number = in.readByte();
        boolean provided = in.readBoolean();
        int unknown = 0;
        if (invtype == 11) {
          unknown = in.readInt();
        }
        if (invtype == 0) {
          Chest adjacent = server.data.chests.adjacentChest(player.openedChest());
          if (!server.data.chests.isChest(player.openedChest())) {
            if (adjacent == null) {
              server.data.chests.addOpenChest(player.openedChest());
            } else {
              server.data.chests.giveLock(adjacent.owner, player.openedChest(), adjacent.name);
View Full Code Here


    }
    return string.toString();
  }

  private void lockChest(Coordinate coordinate) {
    Chest adjacentChest = server.data.chests.adjacentChest(coordinate);
    if (player.isAttemptLock() || adjacentChest != null && !adjacentChest.isOpen()) {
      if (adjacentChest != null && !adjacentChest.isOpen()) {
        server.data.chests.giveLock(adjacentChest.owner, coordinate, adjacentChest.name);
      } else {
        if (adjacentChest != null) {
          adjacentChest.lock(player);
          adjacentChest.name = player.nextChestName();
        }
        server.data.chests.giveLock(player, coordinate, player.nextChestName());
      }
      player.setAttemptedAction(null);
View Full Code Here

TOP

Related Classes of simpleserver.config.data.Chests.Chest

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.