Examples of BlockState


Examples of org.bukkit.block.BlockState

        block.setLine(i, lines[i]);
      }
      block.update(true);
      // lets get some light in here
      if (this.wall == Direction.NORTH() || this.wall == Direction.SOUTH()) {
        BlockState one = this.lobbyMiddleWallBlock.getBlock().getRelative(BlockFace.DOWN).getRelative(Direction.WEST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
        one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
        one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
        one.update(true);
        one = this.lobbyMiddleWallBlock.getBlock().getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
        one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
        one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
        one.update(true);
      } else {
        BlockState one = this.lobbyMiddleWallBlock.getBlock().getRelative(BlockFace.DOWN).getRelative(Direction.NORTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
        one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
        one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
        one.update(true);
        one = this.lobbyMiddleWallBlock.getBlock().getRelative(BlockFace.DOWN).getRelative(Direction.SOUTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
        one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
        one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
        one.update(true);
      }
    } else {
      War.war.log("Failed to initalize zone lobby for zone " + this.warzone.getName(), java.util.logging.Level.WARNING);
    }
  }
View Full Code Here

Examples of org.bukkit.block.BlockState

     
      // minimal air path
      this.clearGatePath(block, front, leftSide, rightSide, true);
     
      // gate blocks
      BlockState lightBlock = block.getRelative(BlockFace.DOWN).getState();
      lightBlock.setType(warzone.getLobbyMaterials().getLightBlock().getType());
      lightBlock.setData(warzone.getLobbyMaterials().getLightBlock().getData());
      lightBlock.update(true);
      this.setBlock(block.getRelative(leftSide), teamKind);
      this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP), teamKind);
      this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), teamKind);
      this.setBlock(block.getRelative(rightSide), teamKind);
      this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP), teamKind);
View Full Code Here

Examples of org.bukkit.block.BlockState

     
      // minimal air path
      this.clearGatePath(block, front, leftSide, rightSide, false);

      // gate blocks
      BlockState lightBlock = block.getRelative(BlockFace.DOWN).getState();
      lightBlock.setType(warzone.getLobbyMaterials().getLightBlock().getType());
      lightBlock.setData(warzone.getLobbyMaterials().getLightBlock().getData());
      lightBlock.update(true);
      Block[] updateBlocks = {
          block.getRelative(leftSide),
          block.getRelative(rightSide).getRelative(BlockFace.UP),
          block.getRelative(leftSide).getRelative(BlockFace.UP)
              .getRelative(BlockFace.UP),
          block.getRelative(rightSide),
          block.getRelative(leftSide).getRelative(BlockFace.UP),
          block.getRelative(rightSide).getRelative(BlockFace.UP)
              .getRelative(BlockFace.UP),
          block.getRelative(BlockFace.UP).getRelative(BlockFace.UP) };
      for (Block update : updateBlocks) {
        BlockState state = update.getState();
        state.setType(frame.getType());
        state.setData(frame.getData());
        state.update(true);
      }
    }
  }
View Full Code Here

Examples of org.bukkit.block.BlockState

      }
    }
  }

  private void setBlock(Block block, TeamKind kind) {
    BlockState blockState = block.getState();
    blockState.setType(kind.getBlockHead().getType());
    blockState.setData(kind.getBlockHead().getData());
    blockState.update(true);
  }
View Full Code Here

Examples of org.bukkit.block.BlockState

     
      // minimal air path
      this.clearGatePath(autoAssignGateBlock, front, leftSide, rightSide, false);
     
      // gate blocks
      BlockState lightBlock = autoAssignGateBlock.getRelative(BlockFace.DOWN).getState();
      lightBlock.setType(warzone.getLobbyMaterials().getLightBlock().getType());
      lightBlock.setData(warzone.getLobbyMaterials().getLightBlock().getData());
      lightBlock.update(true);
      int size = teams.size();
      if (size > 0) {
        TeamKind[] doorBlockKinds = new TeamKind[7];
        for (int i = 0; i < 7; i++) {
          doorBlockKinds[i] = teams.get(i % size).getKind();
View Full Code Here

Examples of org.bukkit.block.BlockState

      Block relative = corner1.getRelative(x, y, z);
      int xi = relative.getX() - minX, yi = relative.getY() - minY, zi = relative.getZ() - minZ;
      if (changes != null) {
        changes[xi][yi][zi] = true;
      }
      BlockState modify = relative.getState();
      ItemStack data = new ItemStack(Material.valueOf(query.getString("type")), 0, query.getShort("data"));
      if (modify.getType() != data.getType() || !modify.getData().equals(data.getData())) {
        // Update the type & data if it has changed
        modify.setType(data.getType());
        modify.setData(data.getData());
        modify.update(true, false); // No-physics update, preventing the need for deferring blocks
        modify = corner1.getRelative(x, y, z).getState(); // Grab a new instance
      }
      if (query.getString("metadata") == null || query.getString("metadata").isEmpty()) {
        continue;
      }
      try {
        if (modify instanceof Sign) {
          final String[] lines = query.getString("metadata").split("\n");
          for (int i = 0; i < lines.length; i++) {
            ((Sign) modify).setLine(i, lines[i]);
          }
          modify.update(true, false);
        }
       
        // Containers
        if (modify instanceof InventoryHolder) {
          YamlConfiguration config = new YamlConfiguration();
          config.loadFromString(query.getString("metadata"));
          ((InventoryHolder) modify).getInventory().clear();
          for (Object obj : config.getList("items")) {
            if (obj instanceof ItemStack) {
              ((InventoryHolder) modify).getInventory().addItem((ItemStack) obj);
            }
          }
          modify.update(true, false);
        }

        // Notes
        if (modify instanceof NoteBlock) {
          String[] split = query.getString("metadata").split("\n");
          Note note = new Note(Integer.parseInt(split[1]), Tone.valueOf(split[0]), Boolean.parseBoolean(split[2]));
          ((NoteBlock) modify).setNote(note);
          modify.update(true, false);
        }

        // Records
        if (modify instanceof Jukebox) {
          ((Jukebox) modify).setPlaying(Material.valueOf(query.getString("metadata")));
          modify.update(true, false);
        }
       
        // Skulls
        if (modify instanceof Skull) {
          String[] opts = query.getString("metadata").split("\n");
          if (!opts[0].isEmpty()) {
            ((Skull) modify).setOwner(opts[0]);
          }
          ((Skull) modify).setSkullType(SkullType.valueOf(opts[1]));
          ((Skull) modify).setRotation(BlockFace.valueOf(opts[2]));
          modify.update(true, false);
        }
       
        // Command blocks
        if (modify instanceof CommandBlock) {
          final String[] commandArray = query.getString("metadata").split("\n");
          ((CommandBlock) modify).setName(commandArray[0]);
          ((CommandBlock) modify).setCommand(commandArray[1]);
          modify.update(true, false);
        }

        // Creature spawner
        if (modify instanceof CreatureSpawner) {
          ((CreatureSpawner) modify).setSpawnedType(EntityType.valueOf(query.getString("metadata")));
          modify.update(true, false);
        }
      } catch (Exception ex) {
        War.war.getLogger().log(Level.WARNING, "Exception loading some tile data. x:" + x + " y:" + y + " z:" + z + " type:" + modify.getType().toString() + " data:" + modify.getData().toString(), ex);
      }
    }
    query.close();
    stmt.close();
    return changed;
View Full Code Here

Examples of org.bukkit.block.BlockState

            for (int z = volume.getMinZ(); z <= volume.getMaxZ(); z++) {
              int xi = x - minX, yi = y - minY, zi = z - minZ;
              if (!changes[xi][yi][zi]) {
                changes[xi][yi][zi] = true;
                airChanges++;
                BlockState state = volume.getWorld().getBlockAt(x, y, z).getState();
                if (state.getType() != Material.AIR) {
                  state.setType(Material.AIR);
                  state.update(true, false);
                }
                if (airChanges >= speed) {
                  this.displayStatusMessage();
                  break air;
                }
View Full Code Here

Examples of org.bukkit.block.BlockState

    volume.setCornerTwo(corner2);
    volume.getBlocks().clear();
    ResultSet query = stmt.executeQuery("SELECT * FROM " + prefix + "_blocks");
    while (query.next()) {
      int x = query.getInt("x"), y = query.getInt("y"), z = query.getInt("z");
      BlockState modify = corner1.getRelative(x, y, z).getState();
      ItemStack data = new ItemStack(Material.valueOf(query.getString("type")), 0, query.getShort("data"));
      modify.setType(data.getType());
      modify.setData(data.getData());
      volume.getBlocks().add(modify);
    }
    query.close();
    stmt.close();
  }
View Full Code Here

Examples of org.bukkit.block.BlockState

          // Make sure we are using zone volume-relative coords
          final Block block = volume.getWorld().getBlockAt(x, y, z);
          if (block.getType() == Material.AIR) {
            continue; // Do not save air blocks to the file anymore.
          }
          final BlockState state = block.getState();
          dataStmt.setInt(1, block.getX() - volume.getCornerOne().getBlockX());
          dataStmt.setInt(2, block.getY() - volume.getCornerOne().getBlockY());
          dataStmt.setInt(3, block.getZ() - volume.getCornerOne().getBlockZ());
          dataStmt.setString(4, block.getType().name());
          dataStmt.setShort(5, state.getData().toItemStack().getDurability());
          if (state instanceof Sign) {
            final String signText = StringUtils.join(((Sign) block.getState()).getLines(), "\n");
            dataStmt.setString(6, signText);
          } else if (state instanceof InventoryHolder) {
            List<ItemStack> items = Arrays.asList(((InventoryHolder) block.getState()).getInventory().getContents());
View Full Code Here

Examples of org.bukkit.block.BlockState

    int x = this.location.getBlockX();
    int y = this.location.getBlockY();
    int z = this.location.getBlockZ();
   
    // center
    BlockState current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
    current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
    current.update(true);

    // inner ring
    current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).getState();
    current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).getState();
    current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).getState();
    current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).getState();
    current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
    current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).getState();
    current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).getState();
    current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).getState();
    current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).getState();
    current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
    current.update(true);

    // block holder
    current = this.warzone.getWorld().getBlockAt(x, y, z).getState();
    current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
    current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
    current.update(true);
    this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.TNT);
  }
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.