private void radialRemoval(final SnipeData v) {
    final Chunk _targetChunk = this.getTargetBlock().getChunk();
    int _entityCount = 0;
    int _chunkCount = 0;

    _entityCount += this.removeEntities(_targetChunk);

    for (int _x = _targetChunk.getX() - v.getBrushSize();
        _x <= _targetChunk.getX() + v.getBrushSize();
        _x++) {
      for (int _z = _targetChunk.getZ() - v.getBrushSize();
          _z <= _targetChunk.getZ() + v.getBrushSize();
          _z++) {
        _entityCount += removeEntities(this.getWorld().getChunkAt(_x, _z));
        _chunkCount++;
      }
    }
    v.sendMessage(
        ChatColor.GREEN
            + "Removed "
            + ChatColor.RED
            + _entityCount
            + ChatColor.GREEN
            + " entities out of "
            + ChatColor.BLUE
            + _chunkCount
            + ChatColor.GREEN
            + " chunks.");
  }
 @Override
 public void init(com.thevoxelbox.voxelsniper.SnipeData v) {
   w = v.getWorld();
   d = v.getData();
   i = v.getVoxelId();
   ir = v.getReplaceId();
 }
  private void radialRemoval(SnipeData v) {
    final Chunk targetChunk = getTargetBlock().getChunk();
    int entityCount = 0;
    int chunkCount = 0;

    entityCount += removeEntities(targetChunk);

    int radius = Math.round(v.getBrushSize() / 16);

    for (int x = targetChunk.getX() - radius; x <= targetChunk.getX() + radius; x++) {
      for (int z = targetChunk.getZ() - radius; z <= targetChunk.getZ() + radius; z++) {
        entityCount += removeEntities(getWorld().getChunkAt(x, z));
        chunkCount++;
      }
    }
    v.sendMessage(
        ChatColor.GREEN
            + "Removed "
            + ChatColor.RED
            + entityCount
            + ChatColor.GREEN
            + " entities out of "
            + ChatColor.BLUE
            + chunkCount
            + ChatColor.GREEN
            + " chunks.");
  }
  @Override
  public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
    final String _param = par[1];

    if (_param.equalsIgnoreCase("info")) {
      v.sendMessage(ChatColor.GOLD + "Clone / Stamp Cylinder brush parameters");
      v.sendMessage(ChatColor.GREEN + "cs f -- Activates Fill mode");
      v.sendMessage(ChatColor.GREEN + "cs a -- Activates No-Air mode");
      v.sendMessage(ChatColor.GREEN + "cs d -- Activates Default mode");
    }
    if (_param.equalsIgnoreCase("a")) {
      this.setStamp(StampType.NO_AIR);
      this.reSort();
      v.sendMessage(ChatColor.AQUA + "No-Air stamp brush");
    } else if (_param.equalsIgnoreCase("f")) {
      this.setStamp(StampType.FILL);
      this.reSort();
      v.sendMessage(ChatColor.AQUA + "Fill stamp brush");
    } else if (_param.equalsIgnoreCase("d")) {
      this.setStamp(StampType.DEFAULT);
      this.reSort();
      v.sendMessage(ChatColor.AQUA + "Default stamp brush");
    } else if (_param.startsWith("c")) {
      v.setcCen(Integer.parseInt(_param.replace("c", "")));
      v.sendMessage(ChatColor.BLUE + "Center set to " + v.getcCen());
    }
  }
Beispiel #5
0
  @Override
  protected final void powder(final com.thevoxelbox.voxelsniper.SnipeData v) {
    this.setBlockPositionX(this.getTargetBlock().getX());
    this.setBlockPositionY(this.getTargetBlock().getY());
    this.setBlockPositionZ(this.getTargetBlock().getZ());

    this.bsize = v.getBrushSize();

    this.snap = new eBlock[0][0][0];
    this.reverse = true;

    this.erosion(v);
  }
Beispiel #6
0
  @Override
  public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
    if (par[1].equalsIgnoreCase("info")) {
      v.sendMessage(ChatColor.GOLD + "Erode brush parameters");
      v.sendMessage(ChatColor.RED + "NOT for litesnipers:");
      v.sendMessage(ChatColor.GREEN + "b[number] (ex:   b23) Sets your sniper brush size.");
      v.sendMessage(
          ChatColor.AQUA
              + "e[number] (ex:  e3) Sets the number of minimum exposed faces to erode a block.");
      v.sendMessage(
          ChatColor.BLUE
              + "f[number] (ex:  f5) Sets the number of minumum faces containing a block to place a block.");
      v.sendMessage(
          ChatColor.DARK_BLUE
              + "re[number] (ex:  re3) Sets the number of recursions the brush will perform erosion.");
      v.sendMessage(
          ChatColor.DARK_GREEN
              + "rf[number] (ex:  rf5) Sets the number of recursions the brush will perform filling.");
      v.sendMessage(
          ChatColor.AQUA
              + "/b d false -- will turn off true circle algorithm /b b true will switch back. (true is default for this brush.)");
      v.sendMessage(ChatColor.GOLD + "For user-friendly pre-sets, type /b e info2.");
      return;
    }
    if (par[1].equalsIgnoreCase("info2")) {
      v.sendMessage(
          ChatColor.GOLD
              + "User-friendly Preset Options.  These are for the arrow.  Powder will do reverse for the first two (for fast switching):");
      v.sendMessage(ChatColor.BLUE + "OK for litesnipers:");
      v.sendMessage(
          ChatColor.GREEN + "/b e melt -- for melting away protruding corners and edges.");
      v.sendMessage(ChatColor.AQUA + "/b e fill -- for building up inside corners");
      v.sendMessage(
          ChatColor.AQUA
              + "/b e smooth -- For the most part, does not change total number of blocks, but smooths the shape nicely.  Use as a finishing touch for the most part, before overlaying grass and trees, etc.");
      v.sendMessage(
          ChatColor.BLUE
              + "/b e lift-- More or less raises each block in the brush area blockPositionY one"); // Giltwist
      return;
    }
    for (int x = 1; x < par.length; x++) {
      try {
        if (par[x].startsWith("melt")) {
          this.fillRecursion = 1;
          this.erodeRecursion = 1;
          this.fillFace = 5;
          this.erodeFace = 2;
          v.owner().setBrushSize(10);
          v.sendMessage(ChatColor.AQUA + "Melt mode. (/b e e2 f5 re1 rf1 b10)");
          continue;
        } else if (par[x].startsWith("fill")) {
          this.fillRecursion = 1;
          this.erodeRecursion = 1;
          this.fillFace = 2;
          this.erodeFace = 5;
          v.owner().setBrushSize(8);
          v.sendMessage(ChatColor.AQUA + "Fill mode. (/b e e5 f2 re1 rf1 b8)");
          continue;
        } else if (par[x].startsWith("smooth")) {
          this.fillRecursion = 1;
          this.erodeRecursion = 1;
          this.fillFace = 3;
          this.erodeFace = 3;
          v.owner().setBrushSize(16);
          v.sendMessage(ChatColor.AQUA + "Smooth mode. (/b e e3 f3 re1 rf1 b16)");
          continue;
        } else if (par[x].startsWith("lift")) { // Giltwist
          this.fillRecursion = 1;
          this.erodeRecursion = 0;
          this.fillFace = 1;
          this.erodeFace = 6;
          v.owner().setBrushSize(10);
          v.sendMessage(ChatColor.AQUA + "Lift mode. (/b e e6 f1 re0 rf1 b10)");
          continue;
        } else if (par[x].startsWith("true")) {
          this.trueCircle = 0.5;
          v.sendMessage(ChatColor.AQUA + "True circle mode ON." + this.erodeRecursion);
          continue;
        } else if (par[x].startsWith("false")) {
          this.trueCircle = 0;
          v.sendMessage(ChatColor.AQUA + "True circle mode OFF." + this.erodeRecursion);
          continue;
        } else if (par[x].startsWith("rf")) {
          this.fillRecursion = Integer.parseInt(par[x].replace("rf", ""));
          v.sendMessage(ChatColor.BLUE + "Fill recursion amount set to " + this.fillRecursion);
          continue;
        } else if (par[x].startsWith("re")) {
          this.erodeRecursion = Integer.parseInt(par[x].replace("re", ""));
          v.sendMessage(ChatColor.AQUA + "Erosion recursion amount set to " + this.erodeRecursion);
          continue;

        } else if (par[x].startsWith("f")) {
          this.fillFace = Integer.parseInt(par[x].replace("f", ""));
          v.sendMessage(ChatColor.BLUE + "Fill minumum touching faces set to " + this.fillFace);
          continue;
        } else if (par[x].startsWith("b")) {
          v.owner().setBrushSize(Integer.parseInt(par[x].replace("b", "")));
          // v.sendMessage(ChatColor.GREEN + "Brush size set to " + v.brushSize); // -
          // setBrushSize(#) already prints info
          continue;
        } else if (par[x].startsWith("e")) {
          this.erodeFace = Integer.parseInt(par[x].replace("e", ""));
          v.sendMessage(ChatColor.AQUA + "Erosion minimum exposed faces set to " + this.erodeFace);
          continue;
        } else {
          v.sendMessage(
              ChatColor.RED
                  + "Invalid brush parameters! use the info parameter to display parameter info.");
        }
      } catch (final Exception e) {
        v.sendMessage(
            ChatColor.RED
                + "Invalid brush parameters! \""
                + par[x]
                + "\" is not a valid statement. Please use the 'info' parameter to display parameter info.");
      }
    }
  }
Beispiel #7
0
  private void erosion(final SnipeData v) {
    if (this.reverse) {
      int temp = this.erodeFace;
      this.erodeFace = this.fillFace;
      this.fillFace = temp;
      temp = this.erodeRecursion;
      this.erodeRecursion = this.fillRecursion;
      this.fillRecursion = temp;
    }
    final Undo h = new Undo(this.getTargetBlock().getWorld().getName());

    if (this.erodeFace >= 0 && this.erodeFace <= 6) {
      for (int er = 0; er < this.erodeRecursion; er++) {
        this.getMatrix();

        final int derp = this.bsize + 1;

        final double bpow = Math.pow(this.bsize + this.trueCircle, 2);
        for (int z = 1; z < this.snap.length - 1; z++) {

          final double zpow = Math.pow(z - derp, 2);
          for (int x = 1; x < this.snap.length - 1; x++) {

            final double xpow = Math.pow(x - derp, 2);
            for (int y = 1; y < this.snap.length - 1; y++) {

              if (((xpow + Math.pow(y - derp, 2) + zpow) <= bpow)) {
                if (this.erode(x, y, z)) {
                  this.snap[x][y][z].b.setTypeId(0);
                }
              }
            }
          }
        }
      }
    }
    if (this.fillFace >= 0 && this.fillFace <= 6) {
      for (int fr = 0; fr < this.fillRecursion; fr++) {
        this.getMatrix();

        final int derp = this.bsize + 1;

        final double bpow = Math.pow(this.bsize + 0.5, 2);
        for (int z = 1; z < this.snap.length - 1; z++) {

          final double zpow = Math.pow(z - derp, 2);
          for (int x = 1; x < this.snap.length - 1; x++) {

            final double xpow = Math.pow(x - derp, 2);
            for (int y = 1; y < this.snap.length - 1; y++) {

              if (((xpow + Math.pow(y - derp, 2) + zpow) <= bpow)) {
                if (this.fill(x, y, z)) {
                  this.snap[x][y][z].b.setTypeId(this.snap[x][y][z].id);
                }
              }
            }
          }
        }
      }
    }

    for (int x = 0; x < this.firstSnap.length; x++) {
      for (int y = 0; y < this.firstSnap.length; y++) {
        for (int z = 0; z < this.firstSnap.length; z++) {
          final eBlock e = this.firstSnap[x][y][z];
          if (e.i != e.b.getTypeId()) {
            h.put(e.b);
          }
        }
      }
    }

    v.storeUndo(h);
    if (this
        .reverse) { // if you dont put it back where it was, powder flips back and forth from fill
                    // to erode each time
      int temp = this.erodeFace;
      this.erodeFace = this.fillFace;
      this.fillFace = temp;
      temp = this.erodeRecursion;
      this.erodeRecursion = this.fillRecursion;
      this.fillRecursion = temp;
    }
  }
Beispiel #8
0
 /**
  * Scroll painting backwards
  *
  * @param v Sniper caller
  */
 @Override
 protected final void powder(final com.thevoxelbox.voxelsniper.SnipeData v) {
   PaintingWrapper.paint(v.owner().getPlayer(), true, true, 0);
 }
  /**
   * The clone method is used to grab a snapshot of the selected area dictated blockPositionY
   * targetBlock.x y z v.brushSize v.voxelHeight and v.cCen.
   *
   * <p>x y z -- initial center of the selection v.brushSize -- the radius of the cylinder
   * v.voxelHeight -- the heigth of the cylinder c.cCen -- the offset on the Y axis of the selection
   * ( bottom of the cylinder ) as blockPositionY: Bottom_Y = targetBlock.y + v.cCen;
   *
   * @param v the caller
   */
  private void clone(final SnipeData v) {
    final int _brushSize = v.getBrushSize();
    this.clone.clear();
    this.fall.clear();
    this.drop.clear();
    this.solid.clear();
    this.sorted = false;

    int _starringPoint = this.getBlockPositionY() + v.getcCen();
    int _yTopEnd = this.getBlockPositionY() + v.getVoxelHeight() + v.getcCen();

    if (_starringPoint < 0) {
      _starringPoint = 0;
      v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position.");
    } else if (_starringPoint > this.getWorld().getMaxHeight() - 1) {
      _starringPoint = this.getWorld().getMaxHeight() - 1;
      v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position.");
    }

    if (_yTopEnd < 0) {
      _yTopEnd = 0;
      v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position.");
    } else if (_yTopEnd > this.getWorld().getMaxHeight() - 1) {
      _yTopEnd = this.getWorld().getMaxHeight() - 1;
      v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position.");
    }

    final double _bPow = Math.pow(_brushSize, 2);

    for (int _z = _starringPoint; _z < _yTopEnd; _z++) {
      this.clone.add(
          new BlockWrapper(
              this.clampY(this.getBlockPositionX(), _z, this.getBlockPositionZ()),
              0,
              _z - _starringPoint,
              0));
      for (int _y = 1; _y <= _brushSize; _y++) {
        this.clone.add(
            new BlockWrapper(
                this.clampY(this.getBlockPositionX(), _z, this.getBlockPositionZ() + _y),
                0,
                _z - _starringPoint,
                _y));
        this.clone.add(
            new BlockWrapper(
                this.clampY(this.getBlockPositionX(), _z, this.getBlockPositionZ() - _y),
                0,
                _z - _starringPoint,
                -_y));
        this.clone.add(
            new BlockWrapper(
                this.clampY(this.getBlockPositionX() + _y, _z, this.getBlockPositionZ()),
                _y,
                _z - _starringPoint,
                0));
        this.clone.add(
            new BlockWrapper(
                this.clampY(this.getBlockPositionX() - _y, _z, this.getBlockPositionZ()),
                -_y,
                _z - _starringPoint,
                0));
      }
      for (int _x = 1; _x <= _brushSize; _x++) {
        final double _xPow = Math.pow(_x, 2);
        for (int _y = 1; _y <= _brushSize; _y++) {
          if ((_xPow + Math.pow(_y, 2)) <= _bPow) {
            this.clone.add(
                new BlockWrapper(
                    this.clampY(this.getBlockPositionX() + _x, _z, this.getBlockPositionZ() + _y),
                    _x,
                    _z - _starringPoint,
                    _y));
            this.clone.add(
                new BlockWrapper(
                    this.clampY(this.getBlockPositionX() + _x, _z, this.getBlockPositionZ() - _y),
                    _x,
                    _z - _starringPoint,
                    -_y));
            this.clone.add(
                new BlockWrapper(
                    this.clampY(this.getBlockPositionX() - _x, _z, this.getBlockPositionZ() + _y),
                    -_x,
                    _z - _starringPoint,
                    _y));
            this.clone.add(
                new BlockWrapper(
                    this.clampY(this.getBlockPositionX() - _x, _z, this.getBlockPositionZ() - _y),
                    -_x,
                    _z - _starringPoint,
                    -_y));
          }
        }
      }
    }
    v.sendMessage(
        ChatColor.GREEN
            + String.valueOf(this.clone.size())
            + ChatColor.AQUA
            + " blocks copied sucessfully.");
  }
  private boolean set(final Block bl, final SnipeData v) {
    if (this.block == null) {
      this.block = bl;
      return true;
    } else {
      if (!this.block.getWorld().getName().equals(bl.getWorld().getName())) {
        v.sendMessage(ChatColor.RED + "You selected points in different worlds!");
        this.block = null;
        return true;
      }

      final int _voxelMaterialId = v.getVoxelId();
      final int _voxelReplaceMaterialId = v.getReplaceId();

      final int _lowx = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX();
      final int _lowy = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY();
      final int _lowz = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ();
      final int _highx = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX();
      final int _highy = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
      final int _highz = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();

      if (Math.abs(_highx - _lowx) * Math.abs(_highz - _lowz) * Math.abs(_highy - _lowy)
          > MAX_SIZE) {
        v.sendMessage(
            ChatColor.RED
                + "Selection size above hardcoded limit, please use a smaller selection.");
      } else {
        final ArrayList<Block> _blocks =
            new ArrayList<Block>(
                ((Math.abs(_highx - _lowx) * Math.abs(_highz - _lowz) * Math.abs(_highy - _lowy))
                    / 2));
        for (int _y = _lowy; _y <= _highy; _y++) {
          for (int _x = _lowx; _x <= _highx; _x++) {
            for (int _z = _lowz; _z <= _highz; _z++) {
              if (this.getWorld().getBlockTypeIdAt(_x, _y, _z) == _voxelReplaceMaterialId) {
                continue;
              } else if (this.getWorld().getBlockTypeIdAt(_x + 1, _y, _z)
                  == _voxelReplaceMaterialId) {
                continue;
              } else if (this.getWorld().getBlockTypeIdAt(_x - 1, _y, _z)
                  == _voxelReplaceMaterialId) {
                continue;
              } else if (this.getWorld().getBlockTypeIdAt(_x, _y, _z + 1)
                  == _voxelReplaceMaterialId) {
                continue;
              } else if (this.getWorld().getBlockTypeIdAt(_x, _y, _z - 1)
                  == _voxelReplaceMaterialId) {
                continue;
              } else if (this.getWorld().getBlockTypeIdAt(_x, _y + 1, _z)
                  == _voxelReplaceMaterialId) {
                continue;
              } else if (this.getWorld().getBlockTypeIdAt(_x, _y - 1, _z)
                  == _voxelReplaceMaterialId) {
                continue;
              } else {
                _blocks.add(this.getWorld().getBlockAt(_x, _y, _z));
              }
            }
          }
        }

        final Undo _undo = new Undo(this.getTargetBlock().getWorld().getName());
        for (final Block _block : _blocks) {
          if (_block.getTypeId() != _voxelMaterialId) {
            _undo.put(_block);
            _block.setTypeId(_voxelMaterialId);
          }
        }
        v.storeUndo(_undo);
        v.sendMessage(ChatColor.AQUA + "Shell complete.");
      }

      this.block = null;
      return false;
    }
  }
 @Override
 protected final void powder(final SnipeData v) {
   if (this.set(this.getLastBlock(), v)) {
     v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one");
   }
 }