solved

Discussion in 'Spigot Plugin Development' started by glasseater, May 16, 2015.

  1. Hey everyone
    Title says it all really. I am wondering how to make it so when I right click a cobble wall near a player it will surround the player in cobblestone? Thanks for any help!
     
  2. What have you tried so far?
     
  3. Code (Text):
    int cx = loc.getBlockX();
          int cy = loc.getBlockY();
          int cz = loc.getBlockZ();
          for (int x = cx - r; x <= cx +r; x++)
              for (int z = cz - r; z <= cz +r; z++)
                  for (int y = (sphere ? cy - r : cy); y < (sphere ? cy + r : cy + h); y++) {
                      double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
                      if (dist < r*r && !(hollow && dist < (r-1)*(r-1))) {
                          Location l = new Location(loc.getWorld(), x, y + plus_y, z);
     
  4. You will need to get the player's location and get the cobblestone location 4x4 or 2x2 , and after he right clicked it , and It must be PlayerInteractEvent , On there you have to if it a right click action and check if the right clicked block is Cobblestone wall , and then do the code.
     
  5. This is how I would do it. You would get the field you want to place and get the location of each block.

    So like

    xxxxx
    xooox
    xoxox
    xooox
    xxxxx

    Considering the x in the center is the player, get the coords or each player around him at the x and set those coords to the block you want. It's just simple Location xBlock1 = player.getLocation().subtract or add to get to that coord.
     
  6. @glasseater create an array of BlockFaces which you want to replace (NORTH, NORTH_EAST, EAST... NORTH_WEST), iterate over that array, use Block#getRelative to get the block and set it's type.