@Override public void init(com.thevoxelbox.voxelsniper.SnipeData v) { w = v.getWorld(); d = v.getData(); i = v.getVoxelId(); ir = v.getReplaceId(); }
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; } }