Package org.bukkit.block

Examples of org.bukkit.block.Block


      LogHelper.showInfo("spawnerList#####[" + Utils.userFriendlyNames(Utils.implode(list, ", ")), sender, ChatColor.AQUA);
      return true;
    }

    if (args.length == 1){
      Block block = player.getTargetBlock(null, 30);
      if (block.getType() == Material.MOB_SPAWNER){
        String entityType = args[0];
        // Get the entity from the string
        EntityType entity = EntityType.fromName(entityType);
        // If the entity is not null and the list contains the entity
        // Then set the spawner to the entity type
        if (entity != null && list.contains(entity.getName())){
          CreatureSpawner spawner = (CreatureSpawner) block.getState();
          // Set the spawner type
          spawner.setSpawnedType(entity);
          LogHelper.showInfo("spawnerSuccess#####[" + Utils.userFriendlyNames(entity.getName()), sender, ChatColor.GREEN);
        } else {
          LogHelper.showInfo("spawnerInvalid", sender, ChatColor.RED);
View Full Code Here


    public static BlockVector block2;
    public static World world;
   
    public void onBlockDamage(BlockDamageEvent event) {
        Player player = event.getPlayer();
        Block block = event.getBlock();
        if (player.getItemInHand().getTypeId() == 281) {
            if (player.hasPermission("ECM.selection"));
            block1 = Util.toVector(block);
            world = block.getWorld();
            player.sendMessage(ChatColor.GREEN + "First point is now set!");
        }
    }
View Full Code Here

   

    public void onPlayerInteract(PlayerInteractEvent event){
  if (!(event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) return;
  Player player = event.getPlayer();
  Block block = event.getClickedBlock();
            if (player.getItemInHand().getTypeId() == 281){
    if (player.hasPermission("ECM.selection"));
                BlockListener.block2 = Util.toVector(block);
                BlockListener.world = block.getWorld();
                player.sendMessage(ChatColor.GREEN + "Second point has been selected!");
            }
    }
View Full Code Here

  public List<Block> getNearestWallBlocks(Location latestPlayerLocation) {
    List<Block> nearestWallBlocks = new ArrayList<Block>();
    if (Math.abs(this.volume.getSoutheastZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX() && latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX() && latestPlayerLocation.getBlockY() >= this.volume.getMinY() && latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
      // near east wall
      Block eastWallBlock = this.world.getBlockAt(latestPlayerLocation.getBlockX() + 1, latestPlayerLocation.getBlockY() + 1, this.volume.getSoutheastZ());
      nearestWallBlocks.add(eastWallBlock);
    }

    if (Math.abs(this.volume.getSoutheastX() - latestPlayerLocation.getBlockX()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockZ() <= this.volume.getNorthwestZ() && latestPlayerLocation.getBlockZ() >= this.volume.getSoutheastZ() && latestPlayerLocation.getBlockY() >= this.volume.getMinY() && latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
      // near south wall
      Block southWallBlock = this.world.getBlockAt(this.volume.getSoutheastX(), latestPlayerLocation.getBlockY() + 1, latestPlayerLocation.getBlockZ());
      nearestWallBlocks.add(southWallBlock);
    }

    if (Math.abs(this.volume.getNorthwestX() - latestPlayerLocation.getBlockX()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockZ() <= this.volume.getNorthwestZ() && latestPlayerLocation.getBlockZ() >= this.volume.getSoutheastZ() && latestPlayerLocation.getBlockY() >= this.volume.getMinY() && latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
      // near north wall
      Block northWallBlock = this.world.getBlockAt(this.volume.getNorthwestX(), latestPlayerLocation.getBlockY() + 1, latestPlayerLocation.getBlockZ());
      nearestWallBlocks.add(northWallBlock);
    }

    if (Math.abs(this.volume.getNorthwestZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX() && latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX() && latestPlayerLocation.getBlockY() >= this.volume.getMinY() && latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
      // near west wall
      Block westWallBlock = this.world.getBlockAt(latestPlayerLocation.getBlockX(), latestPlayerLocation.getBlockY() + 1, this.volume.getNorthwestZ());
      nearestWallBlocks.add(westWallBlock);
    }

    if (Math.abs(this.volume.getMaxY() - latestPlayerLocation.getBlockY()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockX() <= this.volume.getMaxX() && latestPlayerLocation.getBlockX() >= this.volume.getMinX() && latestPlayerLocation.getBlockZ() <= this.volume.getMaxZ() && latestPlayerLocation.getBlockZ() >= this.volume.getMinZ()) {
      // near up wall
      Block upWallBlock = this.world.getBlockAt(latestPlayerLocation.getBlockX(), this.volume.getMaxY(), latestPlayerLocation.getBlockZ());
      nearestWallBlocks.add(upWallBlock);
    }

    if (Math.abs(this.volume.getMinY() - latestPlayerLocation.getBlockY()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockX() <= this.volume.getMaxX() && latestPlayerLocation.getBlockX() >= this.volume.getMinX() && latestPlayerLocation.getBlockZ() <= this.volume.getMaxZ() && latestPlayerLocation.getBlockZ() >= this.volume.getMinZ()) {
      // near down wall
      Block downWallBlock = this.world.getBlockAt(latestPlayerLocation.getBlockX(), this.volume.getMinY(), latestPlayerLocation.getBlockZ());
      nearestWallBlocks.add(downWallBlock);
    }
    return nearestWallBlocks;
    // note: y + 1 to line up 3 sided square with player eyes
  }
View Full Code Here

  public String getName() {
    return this.name;
  }

  public void setLocation(Location location) {
    Block locationBlock = this.warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    this.volume.setCornerOne(locationBlock.getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), 1).getRelative(Direction.SOUTH(), 1));
    this.volume.setCornerTwo(locationBlock.getRelative(BlockFace.UP, 2).getRelative(Direction.WEST(), 1).getRelative(Direction.NORTH(), 1));
    this.volume.saveBlocks();
    this.location = location;
    this.addCakeBlocks();
  }
View Full Code Here

  public String getName() {
    return this.name;
  }

  public void setLocation(Location location) {
    Block locationBlock = this.warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    this.volume.setCornerOne(locationBlock.getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), 2).getRelative(Direction.SOUTH(), 2));
    this.volume.setCornerTwo(locationBlock.getRelative(BlockFace.UP, 2).getRelative(Direction.WEST(), 2).getRelative(Direction.NORTH(), 2));
    this.volume.saveBlocks();
    this.location = location;
   
    this.addMonumentBlocks();
  }
View Full Code Here

        if (!onlyLoadCorners) {
          DeferredBlockResetsJob deferred = new DeferredBlockResetsJob(world);
          int blockReads = 0, visitedBlocks = 0, x = 0, y = 0, z = 0, i = 0, j = 0, k = 0;
          int diskBlockType;
          byte diskBlockData;
          Block worldBlock;
          int worldBlockId;
          volume.clearBlocksThatDontFloat();
          x = volume.getMinX();
          for (i = 0; i < volume.getSizeX(); i++) {
            y = volume.getMinY();
            for (j = 0; j < volume.getSizeY(); j++) {
              z = volume.getMinZ();
              for (k = 0; k < volume.getSizeZ(); k++) {
                try {
                  diskBlockType = blockBytes[visitedBlocks * 2];
                  diskBlockData = blockBytes[visitedBlocks * 2 + 1];

                  worldBlock = volume.getWorld().getBlockAt(x, y, z);
                  worldBlockId = worldBlock.getTypeId();
                  if (worldBlockId != diskBlockType || (worldBlockId == diskBlockType && worldBlock.getData() != diskBlockData) || (worldBlockId == diskBlockType && worldBlock.getData() == diskBlockData && (diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId() || diskBlockType == Material.CHEST.getId() || diskBlockType == Material.DISPENSER.getId()))) {
                    if (diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()) {
                      // Signs read
                      String linesStr = signsReader.readLine();
                      String[] lines = linesStr.split(";;");

                      // Signs set
                      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();
                          for (ItemStack item : items) {
                            if (item != null) {
                              dispenser.getInventory().setItem(ii, item);
                              ii++;
                            }
                          }
                          dispenser.update(true);
                        }
                      }
                    } else if (diskBlockType == Material.WOODEN_DOOR.getId() || diskBlockType == Material.IRON_DOOR_BLOCK.getId()) {
                      // Door blocks
                      deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData));
                    } else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.STONE_BUTTON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LADDER.getId() && ((diskBlockData & 0x04) == 0x04)) || (diskBlockType == Material.RAILS.getId() && ((diskBlockData & 0x02) == 0x02))) && i + 1 != volume.getSizeX()) {
                      // Blocks that hang on a block south of themselves need to make sure that block is there before placing themselves... lol
                      // Change the block itself later on:
                      deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData));
                    } else {
                      // regular block
                      if (diskBlockType >= 0) {
                        worldBlock.setType(Material.getMaterial(diskBlockType));
                        worldBlock.setData(diskBlockData);
                      } else {
                        // The larger than 127 block types were stored as bytes,
                        // but now -128 to -1 are the result of the bad cast from byte
                        // to int array above. To make matters worse let's make this
                        // quick a dirty patch. Anyway everything will break horribly
                        // once block ids get higher than 255.
                        worldBlock.setType(Material.getMaterial(256 + diskBlockType));
                        worldBlock.setData(diskBlockData);
                      }
                    }
                    noOfResetBlocks++;
                  }
                  visitedBlocks++;
View Full Code Here

        cornersWriter.newLine();

        int x = 0;
        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++) {
            z = volume.getMinZ();
            for (int k = 0; k < volume.getSizeZ(); k++) {
              try {
                block = volume.getWorld().getBlockAt(x, y, z);
                typeId = block.getTypeId();
                data = block.getData();
                state = block.getState();

                blocksOutput.write((byte) typeId);
                blocksOutput.write(data);

                if (state instanceof Sign) {
View Full Code Here

    int topHalfOfSide = this.sideSize / 2;

    int x = this.center.getX() + topHalfOfSide;
    int y = this.center.getY() + topHalfOfSide;
    int z = this.center.getZ() + topHalfOfSide;
    Block cornerOne = this.world.getBlockAt(x, y, z);
    this.setCornerOne(cornerOne);

    if (this.sideSize % 2 == 0) { // not a real center, bottom half is larger by 1
      int bottomHalfOfSide = this.sideSize - topHalfOfSide;
      x = this.center.getX() - bottomHalfOfSide;
      y = this.center.getY() - bottomHalfOfSide;
      z = this.center.getZ() - bottomHalfOfSide;
      Block cornerTwo = this.world.getBlockAt(x, y, z);
      this.setCornerTwo(cornerTwo);
    } else {
      x = this.center.getX() - topHalfOfSide;
      y = this.center.getY() - topHalfOfSide;
      z = this.center.getZ() - topHalfOfSide;
      Block cornerTwo = this.world.getBlockAt(x, y, z);
      this.setCornerTwo(cornerTwo);
    }
  }
View Full Code Here

    this.wall = opposite; // a player facing south places a lobby that looks just like a lobby stuck to the north wall

    this.calculateLobbyWidth();
    this.lobbyMiddleWallBlock = lobbyWorld.getBlockAt(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()).getRelative(facing, 6).getLocation();

    Block corner1 = null;
    Block corner2 = null;
    int x = this.lobbyMiddleWallBlock.getBlockX();
    int y = this.lobbyMiddleWallBlock.getBlockY();
    int z = this.lobbyMiddleWallBlock.getBlockZ();

    if (this.wall == Direction.NORTH()) {
View Full Code Here

TOP

Related Classes of org.bukkit.block.Block

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.