public void draggedMouse(Point p) {
		int x = (int) (p.getX() / tileSize);
		int y = (int) (p.getY() / tileSize);
		
		int objLocX = (int) ((p.getX() - (x * tileSize)) / (tileSize / 3));
		int objLocY = (int) ((p.getY() - (y * tileSize)) / (tileSize / 3));
		int objLoc = (objLocY * 3) + objLocX;
		
		int fenceLocX = (int) ((p.getX() - (x * tileSize)) / (tileSize / 4));
		int fenceLocY = (int) ((p.getY() - (y * tileSize)) / (tileSize / 4));
		Tile rightTile = map.getTile(x + 1, y, false);
		Tile downTile = map.getTile(x, y + 1, false);
		
		if (downTile == null)
			if (y + 1 < map.getMapHeight()) {
				downTile = new Tile(x, y + 1);
				map.addTile(x, y + 1, downTile);
			}
		if (rightTile == null) 
			if (x + 1 < map.getMapWidth()) {
				rightTile = new Tile(x + 1, y);
				map.addTile(x + 1, y, rightTile);
			}
		
		/*int relevantType;
		Color c = mainWindow.getOverlayColor();
		
		Tile t = map.getTile(x, y, true);
		if (t == null) {
			map.addTile(x, y, new Tile(x, y));
			t = map.getTile(x, y, true);
		}
		
		if (x < map.getMapWidth() && x >= 0 && y >= 0 && y < map.getMapHeight()) {
			switch (currentState) {
				case TERRAIN_PENCIL:
					relevantType = mainWindow.getSelectedTerrain();
					if (t.getTerrainType(caveLayer) != relevantType)
						currentDragAction.addAction(new TileChange(t, (byte) relevantType, caveLayer, mainWindow.isCaveEntrance(relevantType)));
					break;
				case TERRAIN_BRUSH:
					relevantType = mainWindow.getSelectedTerrain();
					currentDragAction.addAction(new BrushTileChange(map, x, y, mainWindow.getBrushSize(), (byte) relevantType, caveLayer));
					break;
				case TERRAIN_FILL:
					relevantType = mainWindow.getSelectedTerrain();
					if (currentDragAction.isEmpty())
						if (t.getTerrainType(caveLayer) != relevantType)
							currentDragAction.addAction(new TileFill(map, x, y, (byte) relevantType, caveLayer));
					break;
				case TERRAIN_ERASER:
					relevantType = 0;
					currentDragAction.addAction(new TileChange(t, (byte) relevantType, caveLayer, false));
					break;
				case TERRAIN_PICKER:
					if (mainWindow.getSelectedTerrain() != t.getTerrainType(caveLayer))
						mainWindow.forceSelection(ImageType.TERRAIN, t.getTerrainType(caveLayer));
					break;
				case OBJECT_PENCIL:
					relevantType = mainWindow.getSelectedObject();
					if (t.getObjectType(caveLayer, objLoc) != relevantType)
						currentDragAction.addAction(new ObjectChange(t, (byte) relevantType, objLoc, caveLayer));
					break;
				case OBJECT_ERASER:
					relevantType = 0;
					currentDragAction.addAction(new ObjectChange(t, (byte) relevantType, objLoc, caveLayer));
					break;
				case OBJECT_PICKER:
					if (mainWindow.getSelectedObject() != t.getObjectType(caveLayer, objLoc))
						mainWindow.forceSelection(ImageType.OBJECT, t.getObjectType(caveLayer, objLoc));
					break;
				case FENCE_PENCIL:
				case FENCE_ERASER:
					relevantType = (currentState == EditState.FENCE_ERASER ? 0 : mainWindow.getSelectedFence());

					switch (fenceLocX) {
						case 0:
							if (fenceLocY == 1 || fenceLocY == 2)
								if (t.getFenceType(caveLayer, Tile.LEFT_FENCE) != relevantType + 1)
									currentDragAction.addAction(new FenceChange(t, (byte) (relevantType + 1), Tile.LEFT_FENCE, caveLayer));
							break;
						case 1:
						case 2:
							if (fenceLocY == 0) {
								if (t.getFenceType(caveLayer, Tile.TOP_FENCE) != relevantType)
									currentDragAction.addAction(new FenceChange(t, (byte) relevantType, Tile.TOP_FENCE, caveLayer));
							} else if (fenceLocY == 3) {
								if (downTile != null)
									if (downTile.getFenceType(caveLayer, Tile.TOP_FENCE) != relevantType)
										currentDragAction.addAction(new FenceChange(downTile, (byte) relevantType, Tile.TOP_FENCE, caveLayer));
							}
							break;
						case 3:
							if (fenceLocY == 1 || fenceLocY == 2) {								
								if (rightTile != null)
									if (rightTile.getFenceType(caveLayer, Tile.LEFT_FENCE) != relevantType + 1)
										currentDragAction.addAction(new FenceChange(rightTile, (byte) (relevantType + 1), Tile.LEFT_FENCE, caveLayer));
							}
							break;
					}
					break;
				case FENCE_LINE:
					relevantType = mainWindow.getSelectedFence();
					
					if (fenceLineChange == null) {
						switch (fenceLocX) {
							case 0:
								if (fenceLocY == 1 || fenceLocY == 2)
									fenceLineChange = new FenceLine(map, x, y, (byte) relevantType, Tile.LEFT_FENCE, caveLayer);
								break;
							case 1:
							case 2:
								if (fenceLocY == 0) {
									fenceLineChange = new FenceLine(map, x, y, (byte) relevantType, Tile.TOP_FENCE, caveLayer);
								} else if (fenceLocY == 3) {
									fenceLineChange = new FenceLine(map, x, y + 1, (byte) relevantType, Tile.TOP_FENCE, caveLayer);
								}
								break;
							case 3:
								if (fenceLocY == 1 || fenceLocY == 2) {								
									fenceLineChange = new FenceLine(map, x + 1, y, (byte) relevantType, Tile.LEFT_FENCE, caveLayer);
								}
								break;
						}
					}
					
					if (fenceLineChange != null)
						fenceLineChange.update(x, y);
					break;
				case FENCE_PICKER:
					relevantType = mainWindow.getSelectedFence();
					
					switch (fenceLocX) {
						case 0:
							if (fenceLocY == 1 || fenceLocY == 2)
								relevantType = t.getFenceType(caveLayer, Tile.LEFT_FENCE) - 1;
							break;
						case 1:
						case 2:
							if (fenceLocY == 0) {
								relevantType = t.getFenceType(caveLayer, Tile.TOP_FENCE);
							} else if (fenceLocY == 3) {
								relevantType = downTile.getFenceType(caveLayer, Tile.TOP_FENCE);
							}
							break;
						case 3:
							if (fenceLocY == 1 || fenceLocY == 2) {								
								relevantType = rightTile.getFenceType(caveLayer, Tile.LEFT_FENCE) - 1;
							}
							break;
					}
					
					if (relevantType < 0)
						relevantType = 0;
					
					if (mainWindow.getSelectedFence() != relevantType)
						mainWindow.forceSelection(ImageType.FENCE, relevantType);
					break;
				case OVERLAY_PENCIL:
					if (t.getOverlayColor(caveLayer) != c)
						currentDragAction.addAction(new OverlayChange(t, c, caveLayer));
					break;
				case OVERLAY_BRUSH:
					currentDragAction.addAction(new BrushOverlayChange(map, x, y, mainWindow.getBrushSize(), c, caveLayer));
					break;
				case OVERLAY_ERASER:
					c = null;
					if (t.getOverlayColor(caveLayer) != c)
						currentDragAction.addAction(new OverlayChange(t, c, caveLayer));
					break;
				case OVERLAY_PICKER:
					mainWindow.setOverlayColor(t.getOverlayColor(caveLayer));
					break;
				default:
					break;
			}
		}*/
		
		repaint();
	}