Package org.bukkit.block

Examples of org.bukkit.block.BlockState


        }
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onPlayerInteract(PlayerInteractEvent e){
        BlockState bs = e.getClickedBlock().getState();
        Player player = e.getPlayer();

        if (bs instanceof Sign){
            Sign sign = (Sign) bs;
            String[] lines = sign.getLines();
View Full Code Here


    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.CAKE_BLOCK);
  }
View Full Code Here

              || (face == BlockFace.UP && y == this.getMaxY())
              || (face == Direction.NORTH() && x == this.getMinX())
              || (face == Direction.EAST() && z == this.getMinZ())
              || (face == Direction.SOUTH() && x == this.getMaxX())
              || (face == Direction.WEST() && z == this.getMaxZ())) {
            BlockState currentBlock = this.getWorld().getBlockAt(x, y, z).getState();
            currentBlock.setType(faceBlock.getType());
            currentBlock.setData(faceBlock.getData());
            currentBlock.update(true);
          }
        }
      }
    }
  }
View Full Code Here

  public void setFloorOutline(ItemStack outlineBlock) {
    Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
    for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
      for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
        if (x == this.getMinX() || x == this.getMaxX() || z == this.getMinZ() || z == this.getMaxZ()) {
          BlockState currentBlock = this.getWorld().getBlockAt(x, this.getMinY(), z).getState();
          currentBlock.setType(outlineBlock.getType());
          currentBlock.setData(outlineBlock.getData());
          currentBlock.update(true);
        }
      }
    }
  }
View Full Code Here

    final MaterialData mainData = this.warzone.getWarzoneMaterials().getMainBlock().getData();
    final Material light = this.warzone.getWarzoneMaterials().getLightBlock().getType();
    final MaterialData lightData = this.warzone.getWarzoneMaterials().getLightBlock().getData();

    // center
    BlockState current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);

    // inner ring
    current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);

    // outer ring
    current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 2).getState();
    current.setType(light);
    current.setData(lightData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z - 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z - 2).getState();
    current.setType(light);
    current.setData(lightData);
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 2).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 2).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 2).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 2).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
   
    current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 2).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 2).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z + 2).getState();
    current.setType(light);
    current.setData(lightData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z + 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z - 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z - 2).getState();
    current.setType(light);
    current.setData(lightData);
    current.update(true);

    // block holder
    current = this.warzone.getWorld().getBlockAt(x, y, z).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y, z - 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y, z + 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);

    current = this.warzone.getWorld().getBlockAt(x, y + 2, z).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y + 2, z - 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
    current = this.warzone.getWorld().getBlockAt(x, y + 2, z + 1).getState();
    current.setType(main);
    current.setData(mainData);
    current.update(true);
  }
View Full Code Here

                      if (diskBlockType == Material.WALL_SIGN.getId() && ((diskBlockData & 0x04) == 0x04) && i + 1 != volume.getSizeX()) {
                        // A sign post hanging on a wall south of here needs that block to be set first
                        deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData, lines));
                      } else {
                        worldBlock.setType(Material.getMaterial(diskBlockType));
                        BlockState state = worldBlock.getState();
                        state.setData(new org.bukkit.material.Sign(diskBlockType, diskBlockData));
                        if (state instanceof Sign) {
                          Sign sign = (Sign) state;
                          if (lines != null && sign.getLines() != null) {
                            if (lines.length > 0) {
                              sign.setLine(0, lines[0]);
                            }
                            if (lines.length > 1) {
                              sign.setLine(1, lines[1]);
                            }
                            if (lines.length > 2) {
                              sign.setLine(2, lines[2]);
                            }
                            if (lines.length > 3) {
                              sign.setLine(3, lines[3]);
                            }
                            sign.update(true);
                          }
                        }
                      }
                    } else if (diskBlockType == Material.CHEST.getId()) {
                      // Chests read
                      List<ItemStack> items = VolumeMapper.readInventoryString(invsReader.readLine());

                      // Chests set
                      worldBlock.setType(Material.getMaterial(diskBlockType));
                      worldBlock.setData(diskBlockData);
                      BlockState state = worldBlock.getState();
                      if (state instanceof Chest) {
                        Chest chest = (Chest) state;
                        if (items != null) {
                          int ii = 0;
                          chest.getInventory().clear();
                          for (ItemStack item : items) {
                            if (item != null) {
                              chest.getInventory().setItem(ii, item);
                              ii++;
                            }
                          }
                          chest.update(true);
                        }
                      }
                    } else if (diskBlockType == Material.DISPENSER.getId()) {
                      // Dispensers read
                      List<ItemStack> items = VolumeMapper.readInventoryString(invsReader.readLine());

                      // Dispensers set
                      worldBlock.setType(Material.getMaterial(diskBlockType));
                      worldBlock.setData(diskBlockData);
                      BlockState state = worldBlock.getState();
                      if (state instanceof Dispenser) {
                        Dispenser dispenser = (Dispenser) state;
                        if (items != null) {
                          int ii = 0;
                          dispenser.getInventory().clear();
View Full Code Here

        int y = 0;
        int z = 0;
        Block block;
        int typeId;
        byte data;
        BlockState state;

        x = volume.getMinX();
        for (int i = 0; i < volume.getSizeX(); i++) {
          y = volume.getMinY();
          for (int j = 0; j < volume.getSizeY(); j++) {
View Full Code Here

                            // A sign post hanging on a wall south of here will
                            if (diskBlockType == Material.SIGN_POST.getId() && ((diskBlockData & 0x04) == 0x04) && i + 1 != volume.getSizeX()) {
                              deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData, lines));
                            } else {
                              worldBlock.setType(Material.getMaterial(diskBlockType));
                              BlockState state = worldBlock.getState();
                              state.setData(new org.bukkit.material.Sign(diskBlockType, diskBlockData));
                              if (state instanceof Sign) {
                                Sign sign = (Sign) state;
                                if (lines != null && sign.getLines() != null) {
                                  if (lines.length > 0) {
                                    sign.setLine(0, lines[0]);
                                  }
                                  if (lines.length > 1) {
                                    sign.setLine(1, lines[1]);
                                  }
                                  if (lines.length > 2) {
                                    sign.setLine(2, lines[2]);
                                  }
                                  if (lines.length > 3) {
                                    sign.setLine(3, lines[3]);
                                  }
                                  sign.update(true);
                                }
                              }
                            }
                          }
                        } else if (diskBlockType == Material.CHEST.getId()) {
                          // Chests read
                          List<ItemStack> items = null;
                          if (blockSplit.length > 2) {
                            String itemsStr = blockSplit[2];
                            items = PreDeGaulleZoneVolumeMapper.readInventoryString(itemsStr);
                          }

                          // Chests set
                          worldBlock.setType(Material.getMaterial(diskBlockType));
                          worldBlock.setData(diskBlockData);
                          BlockState state = worldBlock.getState();
                          if (state instanceof Chest) {
                            Chest chest = (Chest) state;
                            if (items != null) {
                              int ii = 0;
                              chest.getInventory().clear();
                              for (ItemStack item : items) {
                                if (item != null) {
                                  chest.getInventory().setItem(ii, item);
                                  ii++;
                                }
                              }
                              chest.update(true);
                            }
                          }
                        } else if (diskBlockType == Material.DISPENSER.getId()) {
                          // Dispensers read
                          List<ItemStack> items = null;
                          if (blockSplit.length > 2) {
                            String itemsStr = blockSplit[2];
                            // String itemsStr = lineScanner.nextLine();
                            items = PreDeGaulleZoneVolumeMapper.readInventoryString(itemsStr);
                          }

                          // Dispensers set
                          worldBlock.setType(Material.getMaterial(diskBlockType));
                          worldBlock.setData(diskBlockData);
                          BlockState state = worldBlock.getState();
                          if (state instanceof Dispenser) {
                            Dispenser dispenser = (Dispenser) state;
                            if (items != null) {
                              int ii = 0;
                              dispenser.getInventory().clear();
View Full Code Here

          currentGateBlock.getRelative(back, 2).getRelative(right, 2).getRelative(BlockFace.UP, 2).setType(Material.AIR);
          currentGateBlock.getRelative(back, 2).getRelative(left, 2).setType(Material.AIR);
          currentGateBlock.getRelative(back, 2).getRelative(left, 2).getRelative(BlockFace.UP).setType(Material.AIR);
          currentGateBlock.getRelative(back, 2).getRelative(left, 2).getRelative(BlockFace.UP, 2).setType(Material.AIR);
         
          BlockState cgbdl = currentGateBlock.getRelative(BlockFace.DOWN).getState();
          cgbdl.setType(War.war.getWarhubMaterials().getLightBlock().getType());
          cgbdl.setData(War.war.getWarhubMaterials().getLightBlock().getData());
          cgbdl.update(true);
          // gate blocks
          Block[] gateBlocks = {
              currentGateBlock.getRelative(left),
              currentGateBlock.getRelative(right).getRelative(BlockFace.UP),
              currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP),
              currentGateBlock.getRelative(right),
              currentGateBlock.getRelative(left).getRelative(BlockFace.UP),
              currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP),
              currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP)
              };
          for (Block gateBlock : gateBlocks) {
            BlockState gb = gateBlock.getState();
            gb.setType(War.war.getWarhubMaterials().getGateBlock().getType());
            gb.setData(War.war.getWarhubMaterials().getGateBlock().getData());
            gb.update(true);
          }
          currentGateBlock = currentGateBlock.getRelative(right, 4);
        }
      }
View Full Code Here

        zoneGate.getRelative(BlockFace.UP, 2).getRelative(left.getOppositeFace()).getRelative(back, 1).setType(Material.TORCH);
      } else {
        zoneGate.getRelative(BlockFace.UP, 2).getRelative(left).getRelative(back, 1).setType(Material.AIR);
        zoneGate.getRelative(BlockFace.UP, 2).getRelative(left.getOppositeFace()).getRelative(back, 1).setType(Material.AIR);
       
        BlockState topLeftGateBlock = zoneGate.getRelative(BlockFace.UP, 2).getRelative(left).getState();
        topLeftGateBlock.setType(War.war.getWarhubMaterials().getGateBlock().getType());
        topLeftGateBlock.setData(War.war.getWarhubMaterials().getGateBlock().getData());
        topLeftGateBlock.update(true);
       
        BlockState topRightGateBlock = zoneGate.getRelative(BlockFace.UP, 2).getRelative(left.getOppositeFace()).getState();
        topRightGateBlock.setType(War.war.getWarhubMaterials().getGateBlock().getType());
        topRightGateBlock.setData(War.war.getWarhubMaterials().getGateBlock().getData());
        topRightGateBlock.update(true);
      }
    } else {
      War.war.log("Failed to find warhub gate for " + zone.getName() + " warzone.", Level.WARNING);
    }
  }
View Full Code Here

TOP

Related Classes of org.bukkit.block.BlockState

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.